Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-07-09 11:21:26
Exec Total Coverage
Lines: 8613 12374 69.6%
Functions: 74 107 69.2%
Branches: 5674 10769 52.7%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #include <stdio.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "font.h"
36 #include "zc/replay.h"
37 #include "zc/zc_custom.h"
38 #include "sfx.h"
39 #include "md5.h"
40 #include "zc/ffscript.h"
41 #include "particles.h"
42 #include "dialog/alert.h"
43
44 #ifdef __EMSCRIPTEN__
45 #include "base/emscripten_utils.h"
46 #endif
47
48 //FFScript FFCore;
49 extern FFScript FFCore;
50 extern ZModule zcm;
51 extern zcmodule moduledata;
52 extern uint8_t __isZQuest;
53 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
54 extern particle_list particles;
55 extern void setZScriptVersion(int32_t s_version);
56 //FFSCript FFEngine;
57
58 int32_t temp_ffscript_version = 0;
59 static bool read_ext_zinfo = false, read_zinfo = false;
60 static bool loadquest_report = false;
61 static char const* loading_qst_name = NULL;
62 static byte loading_qst_num = 0;
63
64 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
65 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
66
67 #ifdef _MSC_VER
68 #define strncasecmp _strnicmp
69 #endif
70
71 #ifndef _AL_MALLOC
72 #define _AL_MALLOC(a) _al_malloc(a)
73 #define _AL_FREE(a) _al_free(a)
74 #endif
75
76 using std::string;
77 using std::pair;
78
79 // extern bool debug;
80 extern int32_t hero_animation_speed; //lower is faster animation
81 extern std::vector<mapscr> TheMaps;
82 extern zcmap *ZCMaps;
83 extern MsgStr *MsgStrings;
84 extern DoorComboSet *DoorComboSets;
85 extern dmap *DMaps;
86 extern std::vector<newcombo> combobuf;
87 extern byte *colordata;
88 //extern byte *tilebuf;
89 extern tiledata *newtilebuf;
90 extern byte *trashbuf;
91 extern itemdata *itemsbuf;
92 extern wpndata *wpnsbuf;
93 extern comboclass *combo_class_buf;
94 extern guydata *guysbuf;
95 extern ZCHEATS zcheats;
96 extern zinitdata zinit;
97 extern char palnames[MAXLEVELS][17];
98 extern int32_t memrequested;
99 extern char *byte_conversion(int32_t number, int32_t format);
100 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39 string zScript;
102 39 std::map<int32_t, script_slot_data > ffcmap;
103 39 std::map<int32_t, script_slot_data > globalmap;
104 39 std::map<int32_t, script_slot_data > genericmap;
105 39 std::map<int32_t, script_slot_data > itemmap;
106 39 std::map<int32_t, script_slot_data > npcmap;
107 39 std::map<int32_t, script_slot_data > ewpnmap;
108 39 std::map<int32_t, script_slot_data > lwpnmap;
109 39 std::map<int32_t, script_slot_data > playermap;
110 39 std::map<int32_t, script_slot_data > dmapmap;
111 39 std::map<int32_t, script_slot_data > screenmap;
112 39 std::map<int32_t, script_slot_data > itemspritemap;
113 39 std::map<int32_t, script_slot_data > comboscriptmap;
114 void free_newtilebuf();
115 bool combosread=false;
116 bool mapsread=false;
117 bool fixffcs=false;
118 bool fixpolsvoice=false;
119
120
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
121
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
122
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
123
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
124
125 char qstdat_string[2048] = { 0 };
126
127 static zinfo* load_tmp_zi = NULL;
128
129 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
130 const byte clavio[9]={97,109,111,110,103,117,115,0};
131
132 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
133 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
134
135 extern combo_alias combo_aliases[MAXCOMBOALIASES];
136 extern combo_pool combo_pools[MAXCOMBOPOOLS];
137 const char *qst_error[] =
138 {
139 "OK","File not found","Invalid quest file",
140 "Version not supported","Obsolete version",
141 "Missing new data" , /* but let it pass in ZQuest */
142 "Internal error occurred", "Invalid password",
143 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
144 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
145 };
146
147 //for legacy quests -DD
148 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
149 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
150 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
151 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
152 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
153 };
154
155 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
156
157
158 void delete_combo_aliases()
159 {
160 for(int32_t j(0); j<256; j++)
161 {
162 if(combo_aliases[j].combos != NULL)
163 {
164 delete[] combo_aliases[j].combos;
165 combo_aliases[j].combos=NULL;
166 }
167
168 if(combo_aliases[j].csets != NULL)
169 {
170 delete[] combo_aliases[j].csets;
171 combo_aliases[j].csets=NULL;
172 }
173 }
174
175 }
176
177 char *byte_conversion(int32_t number, int32_t format)
178 {
179 static char num_str[40];
180
181 if(format==-1) //auto
182 {
183 format=1; //bytes
184
185 if(number>1024)
186 {
187 format=2; //kilobytes
188 }
189
190 if(number>1024*1024)
191 {
192 format=3; //megabytes
193 }
194
195 if(number>1024*1024*1024)
196 {
197 format=4; //gigabytes (dude, what are you doing?)
198 }
199 }
200
201 switch(format)
202 {
203 case 1: //bytes
204 sprintf(num_str,"%db",number);
205 break;
206
207 case 2: //kilobytes
208 sprintf(num_str,"%.2fk",float(number)/1024);
209 break;
210
211 case 3: //megabytes
212 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
213 break;
214
215 case 4: //gigabytes
216 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
217 break;
218
219 default:
220 abort();
221 break;
222 }
223
224 return num_str;
225 }
226
227 546 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
228 {
229 static char num_str1[40];
230 static char num_str2[40];
231 static char num_str[80];
232
233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(format1==-1) //auto
234 {
235 546 format1=1; //bytes
236
237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(number1>1024)
238 {
239 546 format1=2; //kilobytes
240 546 }
241
242
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 156 times.
546 if(number1>1024*1024)
243 {
244 156 format1=3; //megabytes
245 156 }
246
247
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(number1>1024*1024*1024)
248 {
249 format1=4; //gigabytes (dude, what are you doing?)
250 }
251 546 }
252
253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(format2==-1) //auto
254 {
255 546 format2=1; //bytes
256
257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(number2>1024)
258 {
259 546 format2=2; //kilobytes
260 546 }
261
262
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 507 times.
546 if(number2>1024*1024)
263 {
264 507 format2=3; //megabytes
265 507 }
266
267
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(number2>1024*1024*1024)
268 {
269 format2=4; //gigabytes (dude, what are you doing?)
270 }
271 546 }
272
273
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 156 times.
✗ Branch 4 not taken.
546 switch(format1)
274 {
275 case 1: //bytes
276 sprintf(num_str1,"%db",number1);
277 break;
278
279 case 2: //kilobytes
280 390 sprintf(num_str1,"%.2fk",float(number1)/1024);
281 390 break;
282
283 case 3: //megabytes
284 156 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
285 156 break;
286
287 case 4: //gigabytes
288 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
289 break;
290
291 default:
292 abort();
293 break;
294 }
295
296
2/5
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 507 times.
✗ Branch 4 not taken.
546 switch(format2)
297 {
298 case 1: //bytes
299 sprintf(num_str2,"%db",number2);
300 break;
301
302 case 2: //kilobytes
303 39 sprintf(num_str2,"%.2fk",float(number2)/1024);
304 39 break;
305
306 case 3: //megabytes
307 507 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
308 507 break;
309
310 case 4: //gigabytes
311 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
312 break;
313
314 default:
315 abort();
316 break;
317 }
318
319 546 sprintf(num_str, "%s/%s", num_str1, num_str2);
320 546 return num_str;
321 }
322
323 char *ordinal(int32_t num)
324 {
325 static const char *ending[4] = {"st","nd","rd","th"};
326 static char ord_str[8];
327
328 char *end;
329 int32_t t=(num%100)/10;
330 int32_t n=num%10;
331
332 if(n>=1 && n<4 && t!=1)
333 end = (char *)ending[n-1];
334 else
335 end = (char *)ending[3];
336
337 sprintf(ord_str,"%d%s",num%10000,end);
338 return ord_str;
339 }
340
341 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
342 {
343 int32_t ret;
344 *version=0;
345 *build=0;
346 byte temp_map_count=map_count;
347 byte temp_midi_flags[MIDIFLAGS_SIZE];
348 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
349
350 zquestheader tempheader;
351
352 if(!f)
353 {
354 return qe_invalid;
355 }
356
357 ret=readheader(f, &tempheader, true);
358
359 if(ret)
360 {
361 return ret;
362 }
363
364 map_count=temp_map_count;
365 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
366 *version=tempheader.zelda_version;
367 *build=tempheader.build;
368 return 0;
369 }
370
371
372 bool find_section(PACKFILE *f, int32_t section_id_requested)
373 {
374
375 if(!f)
376 {
377 return false;
378 }
379
380 int32_t section_id_read;
381 bool catchup=false;
382 word dummy;
383 byte tempbyte;
384 char tempbuf[65536];
385
386
387 switch(section_id_requested)
388 {
389 case ID_RULES:
390 case ID_STRINGS:
391 case ID_MISC:
392 case ID_TILES:
393 case ID_COMBOS:
394 case ID_CSETS:
395 case ID_MAPS:
396 case ID_DMAPS:
397 case ID_DOORS:
398 case ID_ITEMS:
399 case ID_WEAPONS:
400 case ID_COLORS:
401 case ID_ICONS:
402 case ID_INITDATA:
403 case ID_GUYS:
404 case ID_MIDIS:
405 case ID_CHEATS:
406 break;
407
408 default:
409 al_trace("Bad section requested!\n");
410 return false;
411 break;
412 }
413
414 dword section_size;
415
416 //section id
417 if(!p_mgetl(&section_id_read,f,true))
418 {
419 return false;
420 }
421
422 while(!pack_feof(f))
423 {
424 switch(section_id_read)
425 {
426 case ID_RULES:
427 case ID_STRINGS:
428 case ID_MISC:
429 case ID_TILES:
430 case ID_COMBOS:
431 case ID_CSETS:
432 case ID_MAPS:
433 case ID_DMAPS:
434 case ID_DOORS:
435 case ID_ITEMS:
436 case ID_WEAPONS:
437 case ID_COLORS:
438 case ID_ICONS:
439 case ID_INITDATA:
440 case ID_GUYS:
441 case ID_MIDIS:
442 case ID_CHEATS:
443 catchup=false;
444 break;
445
446 default:
447 break;
448 }
449
450
451 while(catchup)
452 {
453 //section id
454 section_id_read=(section_id_read<<8);
455
456 if(!p_getc(&tempbyte,f,true))
457 {
458 return false;
459 }
460
461 section_id_read+=tempbyte;
462 }
463
464 if(section_id_read==section_id_requested)
465 {
466 return true;
467 }
468 else
469 {
470 //section version info
471 if(!p_igetw(&dummy,f,true))
472 {
473 return false;
474 }
475
476 if(!p_igetw(&dummy,f,true))
477 {
478 return false;
479 }
480
481 //section size
482 if(!p_igetl(&section_size,f,true))
483 {
484 return false;
485 }
486
487 //pack_fseek(f, section_size);
488 while(section_size>65535)
489 {
490 pfread(tempbuf,65535,f,true);
491 tempbuf[65535]=0;
492 section_size-=65535;
493 }
494
495 if(section_size>0)
496 {
497 pfread(tempbuf,section_size,f,true);
498 tempbuf[section_size]=0;
499 }
500 }
501
502 //section id
503 if(!p_mgetl(&section_id_read,f,true))
504 {
505 return false;
506 }
507 }
508
509 return false;
510 }
511
512
513
514
515
516 bool valid_zqt(PACKFILE *f)
517 {
518
519 //word tiles_used;
520 //word combos_used;
521 //open the file
522 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
523 if(!f)
524 return false;
525
526 //for now, everything else is valid
527 return true;
528
529 /*int16_t version;
530 byte build;
531
532 //read the version and make sure it worked
533 if(!p_igetw(&version,f,true))
534 {
535 goto error;
536 }
537
538 //read the build and make sure it worked
539 if(!p_getc(&build,f,true))
540 goto error;
541
542 //read the tile info and make sure it worked
543 if(!p_igetw(&tiles_used,f,true))
544 {
545 goto error;
546 }
547
548 for (int32_t i=0; i<tiles_used; i++)
549 {
550 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
551 {
552 goto error;
553 }
554 }
555
556 //read the combo info and make sure it worked
557 if(!p_igetw(&combos_used,f,true))
558 {
559 goto error;
560 }
561 for (int32_t i=0; i<combos_used; i++)
562 {
563 if(!pfread(trashbuf,sizeof(newcombo),f,true))
564 {
565 goto error;
566 }
567 }
568
569 //read the palette info and make sure it worked
570 for (int32_t i=0; i<48; i++)
571 {
572 if(!pfread(trashbuf,newpdTOTAL,f,true))
573 {
574 goto error;
575 }
576 }
577 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
578 {
579 goto error;
580 }
581 for (int32_t i=0; i<MAXLEVELS; i++)
582 {
583 if(!pfread(trashbuf,PALNAMESIZE,f,true))
584 {
585 goto error;
586 }
587 }
588
589 //read the sprite info and make sure it worked
590 for (int32_t i=0; i<MAXITEMS; i++)
591 {
592 if(!pfread(trashbuf,sizeof(itemdata),f,true))
593 {
594 goto error;
595 }
596 }
597
598 for (int32_t i=0; i<MAXWPNS; i++)
599 {
600 if(!pfread(trashbuf,sizeof(wpndata),f,true))
601 {
602 goto error;
603 }
604 }
605
606 //read the triforce pieces info and make sure it worked
607 for (int32_t i=0; i<8; ++i)
608 {
609 if(!p_getc(&trashbuf,f,true))
610 {
611 goto error;
612 }
613 }
614
615
616
617 //read the game icons info and make sure it worked
618 for (int32_t i=0; i<4; ++i)
619 {
620 if(!p_igetw(&trashbuf,f,true))
621 {
622 goto error;
623 }
624 }
625
626 //read the misc colors info and map styles info and make sure it worked
627 if(!pfread(trashbuf,sizeof(zcolors),f,true))
628 {
629 goto error;
630 }
631
632 //read the template screens and make sure it worked
633 byte num_maps;
634 if(!p_getc(&num_maps,f,true))
635 {
636 goto error;
637 }
638 for (int32_t i=0; i<TEMPLATES; i++)
639 {
640 if(!pfread(trashbuf,sizeof(mapscr),f,true))
641 {
642 goto error;
643 }
644 }
645 if (num_maps>1) //dungeon templates
646 {
647 for (int32_t i=0; i<TEMPLATES; i++)
648 {
649 if(!pfread(trashbuf,sizeof(mapscr),f,true))
650 {
651 goto error;
652 }
653 }
654 }
655
656 //yay! it worked! close the file and say everything was ok.
657 pack_fclose(f);
658 return true;
659
660 error:
661 pack_fclose(f);
662 return false;*/
663 }
664
665 bool valid_zqt(const char *filename)
666 {
667 PACKFILE *f=NULL;
668 bool isvalid;
669 int32_t error;
670 f=open_quest_file(&error, filename, false);
671
672 if(!f)
673 {
674 // setPackfilePassword(NULL);
675 return false;
676 }
677
678 isvalid=valid_zqt(f);
679
680 clear_quest_tmpfile();
681 pack_fclose(f);
682
683 // setPackfilePassword(NULL);
684 return isvalid;
685 }
686
687 39 static std::string tmp_file_name;
688 230 void clear_quest_tmpfile()
689 {
690
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 if(tmp_file_name.size())
691 {
692 if(exists(tmp_file_name.c_str()))
693 delete_file(tmp_file_name.c_str());
694 tmp_file_name.clear();
695 }
696 230 }
697 /*
698 .qst file history
699
700 .qst files have always been compressed using allegro's packfiles.
701
702 At some point, an encoding layer was added. The two layers look like this:
703
704 1) The top layer is from us. See decode_file_007.
705 [0-24] Preamble "Zelda Classic Quest File"
706 [25-28] Initial decoding seed value.
707 [29-X] Allegro-encoded payload (AKA "packed" file)
708 [last 4] Checksum
709
710 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
711 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
712 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
713 The oldest quests skip the password part.
714
715 Simply, the job of this function is to peel away the top layer.
716
717 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
718 in opening and saving files. There is no version field, so they decryption key is
719 found via trial-by-error (very slow!)
720
721 There are other file types of interest:
722 - .zqt: quest template files, skips top-layer encryption pass
723 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
724 - .qu?: same as above. automated backup files
725 - .qb?: same as above. automated backup files
726 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
727
728 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
729 files are now "slh!.AG ZC Enhanced Quest File".
730 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
731 */
732 115 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
733 {
734
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (show_progress)
735 {
736 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
737 }
738
739 #ifdef __EMSCRIPTEN__
740 if (em_is_lazy_file(filename))
741 {
742 em_fetch_file(filename);
743 }
744 #endif
745 115 clear_quest_tmpfile();
746 // Note: although this is primarily for loading .qst files, it can also handle all of the
747 // file types mentioned in the comment above. No need to be told if the file being loaded
748 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
749 115 bool top_layer_compressed = false;
750 115 bool compressed = false;
751 115 bool encrypted = false;
752
753 // Input files may or may not include a top layer, which may or may not be compressed.
754 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
755 // with an allegro packfile password (longtan).
756 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
757 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
758 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
759
760 115 bool id_came_from_compressed_file = false;
761 115 const char* packfile_password = "";
762 char id[32];
763 115 id[0] = id[31] = '\0';
764 115 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
765
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 if (!pf)
766 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
767
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 if (pf)
768 {
769 112 id_came_from_compressed_file = true;
770
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (!pack_fread(id, sizeof(id)-1, pf))
771 {
772 pack_fclose(pf);
773 Z_message("Unable to read header string\n");
774 return nullptr;
775 }
776 112 pack_fclose(pf);
777 112 }
778 else
779 {
780 3 FILE* f = fopen(filename, "rb");
781
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
782 {
783 *open_error=qe_notfound;
784 return nullptr;
785 }
786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
787 {
788 fclose(f);
789 Z_message("Unable to read header string\n");
790 return nullptr;
791 }
792 3 fclose(f);
793 }
794
795
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
115 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
796 {
797 // The given file is already just the bottom layer - nothing more to do.
798 // There's no way to rewind a packfile, so just open it again.
799
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (id_came_from_compressed_file)
800 {
801 112 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
802 }
803 else
804 {
805 return pack_fopen_password(filename, F_READ, "");
806 }
807 }
808
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
809 {
810 3 top_layer_compressed = id_came_from_compressed_file;
811 3 compressed = true;
812 3 encrypted = true;
813 3 }
814 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
815 {
816 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
817 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
818
819 char tmpfilename[L_tmpnam];
820 std::tmpnam(tmpfilename);
821 FILE* tf = fopen(tmpfilename, "wb");
822 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
823
824 int c;
825 while ((c = pack_getc(pf)) != EOF)
826 {
827 fputc(c, tf);
828 }
829 fclose(tf);
830 pack_fclose(pf);
831
832 tmp_file_name = tmpfilename; //store so it can be cleaned up later
833
834 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
835 // We should put qsu in the dat file, or use a separate .qst file for new qst.
836 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
837 }
838 else
839 {
840 // Unexpected, this is going to fail some header check later.
841 }
842
843 // Everything below here is legacy code - recently saved quest files will have
844 // returned by now.
845
846 char tmpfilename[L_tmpnam];
847 3 temp_name(tmpfilename);
848 char percent_done[30];
849 3 int32_t current_method=0;
850
851 PACKFILE *f;
852 3 const char *passwd= encrypted ? datapwd : "";
853
854 // oldquest flag is set when an unencrypted qst file is suspected.
855 3 bool oldquest = false;
856 int32_t ret;
857
858
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
859 {
860 3 box_out(filename);
861 3 }
862 else
863 {
864 box_out("new quest"); // Or whatever
865 }
866 3 box_out("...");
867 3 box_eol();
868 3 box_eol();
869
870
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
871 {
872 3 box_out("Decrypting...");
873 3 box_save_x();
874 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
875
876
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
877 {
878 switch(ret)
879 {
880 case 1:
881 box_out("error.");
882 box_eol();
883 box_end(true);
884 *open_error=qe_notfound;
885 return NULL;
886
887 case 2:
888 box_out("error.");
889 box_eol();
890 box_end(true);
891 *open_error=qe_internal;
892 return NULL;
893 // be sure not to delete tmpfilename now...
894 }
895
896 if(ret==5) //old encryption?
897 {
898 current_method++;
899 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
900 box_out(percent_done);
901 box_load_x();
902 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
903 }
904
905 if(ret==5) //old encryption?
906 {
907 current_method++;
908 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
909 box_out(percent_done);
910 box_load_x();
911 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
912 }
913
914 if(ret==5) //old encryption?
915 {
916 current_method++;
917 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
918 box_out(percent_done);
919 box_load_x();
920 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
921 }
922
923 if(ret==5) //old encryption?
924 {
925 current_method++;
926 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
927 box_out(percent_done);
928 box_load_x();
929 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
930 }
931
932 if(ret)
933 {
934 oldquest = true;
935 passwd="";
936 }
937 }
938
939 3 box_out("okay.");
940 3 box_eol();
941 3 }
942 else
943 {
944 oldquest = true;
945 }
946
947 3 box_out("Opening...");
948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
949
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
950 {
951 if((compressed==1)&&(errno==EDOM))
952 {
953 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
954 }
955
956 if(!f)
957 {
958 if(!oldquest)
959 {
960 delete_file(tmpfilename);
961 }
962 box_out("error.");
963 box_eol();
964 box_end(true);
965 *open_error=qe_invalid;
966 return NULL;
967 }
968 }
969
970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
971 {
972 3 delete_file(tmpfilename);
973 3 }
974
975 3 box_out("okay.");
976 3 box_eol();
977
978 3 return f;
979 115 }
980
981 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
982 {
983 char *filename;
984 PACKFILE *f=NULL;
985 int32_t open_error=0;
986
987 strcpy(qstdat_string, "modules/classic/default.qst");
988 if(Header->templatepath[0]==0)
989 {
990 filename=(char *)malloc(2048);
991 strcpy(filename, qstdat_string);
992 }
993 else
994 {
995 // TODO: should be safe to remove this, no one seems to use custom quest templates.
996 filename=Header->templatepath;
997 }
998
999 f=open_quest_file(&open_error, filename, false);
1000
1001 if(Header->templatepath[0]==0)
1002 {
1003 free(filename);
1004 }
1005
1006 if(!f)
1007 {
1008 return NULL;
1009 }
1010
1011 if(validate)
1012 {
1013 if(!valid_zqt(f))
1014 {
1015 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1016 pack_fclose(f);
1017 clear_quest_tmpfile();
1018 return NULL;
1019 }
1020 }
1021
1022 return f;
1023 }
1024
1025 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1026 {
1027 // We absolutely do not support loading from a template file to initialize data outside the editor.
1028 // TODO: move this code into zq/
1029 if (get_app_id() != App::zquest) return false;
1030
1031 combosread=false;
1032 mapsread=false;
1033 fixffcs=false;
1034
1035 switch(section_id)
1036 {
1037 case ID_RULES:
1038 case ID_STRINGS:
1039 case ID_MISC:
1040 case ID_TILES:
1041 case ID_COMBOS:
1042 case ID_CSETS:
1043 case ID_MAPS:
1044 case ID_DMAPS:
1045 case ID_DOORS:
1046 case ID_ITEMS:
1047 case ID_WEAPONS:
1048 case ID_COLORS:
1049 case ID_ICONS:
1050 case ID_INITDATA:
1051 case ID_GUYS:
1052 case ID_MIDIS:
1053 case ID_CHEATS:
1054 case ID_ITEMDROPSETS:
1055 case ID_FAVORITES:
1056 break;
1057
1058 default:
1059 return false;
1060 break;
1061 }
1062
1063 int32_t ret;
1064 word version, build;
1065 PACKFILE *f=NULL;
1066
1067 char deletefilename[1024];
1068 deletefilename[0]=0;
1069
1070 //why is this here?
1071 /*
1072 if(colordata==NULL)
1073 return false;
1074 */
1075
1076 //setPackfilePassword(datapwd);
1077 f=open_quest_template(Header, deletefilename, validate);
1078
1079 if(!f) //no file, nothing to delete
1080 {
1081 // setPackfilePassword(NULL);
1082 return false;
1083 }
1084
1085 ret=get_version_and_build(f, &version, &build);
1086
1087 if(ret||(version==0))
1088 {
1089 pack_fclose(f);
1090 clear_quest_tmpfile();
1091
1092 if(deletefilename[0])
1093 {
1094 delete_file(deletefilename);
1095 }
1096
1097 // setPackfilePassword(NULL);
1098 return false;
1099 }
1100
1101 if(!find_section(f, section_id))
1102 {
1103 al_trace("Can't find section!\n");
1104 pack_fclose(f);
1105 clear_quest_tmpfile();
1106
1107 if(deletefilename[0])
1108 {
1109 delete_file(deletefilename);
1110 }
1111
1112 //setPackfilePassword(NULL);
1113 return false;
1114 }
1115
1116 switch(section_id)
1117 {
1118 case ID_RULES:
1119 //rules
1120 ret=readrules(f, Header, true);
1121 break;
1122
1123 case ID_STRINGS:
1124 //strings
1125 ret=readstrings(f, Header, true);
1126 break;
1127
1128 case ID_MISC:
1129 //misc data
1130 ret=readmisc(f, Header, Misc, true);
1131 break;
1132
1133 case ID_TILES:
1134 //tiles
1135 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1136 break;
1137
1138 case ID_COMBOS:
1139 //combos
1140 clear_combos();
1141 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1142 combosread=true;
1143 break;
1144
1145 case ID_COMBOALIASES:
1146 //combos
1147 ret=readcomboaliases(f, Header, version, build, true);
1148 break;
1149
1150 case ID_CSETS:
1151 //color data
1152 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1153 break;
1154
1155 case ID_MAPS:
1156 //maps
1157 ret=readmaps(f, Header, true);
1158 mapsread=true;
1159 break;
1160
1161 case ID_DMAPS:
1162 //dmaps
1163 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1164 break;
1165
1166 case ID_DOORS:
1167 //door combo sets
1168 ret=readdoorcombosets(f, Header, true);
1169 break;
1170
1171 case ID_ITEMS:
1172 //items
1173 ret=readitems(f, version, build, true);
1174 break;
1175
1176 case ID_WEAPONS:
1177 //weapons
1178 ret=readweapons(f, Header, true);
1179 break;
1180
1181 case ID_COLORS:
1182 //misc. colors
1183 ret=readmisccolors(f, Header, Misc, true);
1184 break;
1185
1186 case ID_ICONS:
1187 //game icons
1188 ret=readgameicons(f, Header, Misc, true);
1189 break;
1190
1191 case ID_INITDATA:
1192 //initialization data
1193 ret=readinitdata(f, Header, true);
1194 break;
1195
1196 case ID_GUYS:
1197 //guys
1198 ret=readguys(f, Header, true);
1199 break;
1200
1201 case ID_MIDIS:
1202 //midis
1203 ret=readtunes(f, Header, tunes, true);
1204 break;
1205
1206 case ID_CHEATS:
1207 //cheat codes
1208 ret=readcheatcodes(f, Header, true);
1209 break;
1210
1211 case ID_ITEMDROPSETS:
1212 //item drop sets
1213 // Why is this one commented out?
1214 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1215 break;
1216
1217 case ID_FAVORITES:
1218 // favorite combos and aliases
1219 ret=readfavorites(f, version, build, true);
1220 break;
1221
1222 default:
1223 ret=-1;
1224 break;
1225 }
1226
1227 pack_fclose(f);
1228 clear_quest_tmpfile();
1229
1230 if(deletefilename[0])
1231 {
1232 delete_file(deletefilename);
1233 }
1234
1235 //setPackfilePassword(NULL);
1236 if(!ret)
1237 {
1238 return true;
1239 }
1240
1241 return false;
1242 }
1243
1244 bool init_tiles(bool validate, zquestheader *Header)
1245 {
1246 return init_section(Header, ID_TILES, NULL, NULL, validate);
1247 }
1248
1249 bool init_combos(bool validate, zquestheader *Header)
1250 {
1251 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1252 }
1253
1254 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1255 {
1256 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1257 }
1258
1259 115 void init_spritelists()
1260 {
1261
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
115 if(FFCore.quest_format[vZelda] < 0x255)
1262 {
1263 85 guys.setMax(255);
1264 85 items.setMax(255);
1265 85 Ewpns.setMax(255);
1266 85 Lwpns.setMax(255);
1267 85 Sitems.setMax(255);
1268 85 chainlinks.setMax(255);
1269 85 decorations.setMax(255);
1270 85 particles.setMax(255);
1271 85 }
1272 else
1273 {
1274 30 guys.setMax(255);
1275 30 items.setMax(255);
1276 30 Ewpns.setMax(255);
1277 30 Lwpns.setMax(255);
1278 30 Sitems.setMax(255);
1279 30 chainlinks.setMax(255);
1280 30 decorations.setMax(255);
1281 30 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1282 }
1283 115 }
1284
1285 39 bool reset_items(bool validate, zquestheader *Header)
1286 {
1287 39 bool ret = true;
1288
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if (get_app_id() == App::zquest)
1289 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1290
1291
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 9984 times.
10023 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1292
1293 39 return ret;
1294 }
1295
1296 bool reset_guys()
1297 {
1298 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1299 init_guys(V_GUYS);
1300 return true;
1301 }
1302
1303 bool reset_wpns(bool validate, zquestheader *Header)
1304 {
1305 bool ret = true;
1306 if (get_app_id() == App::zquest)
1307 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1308
1309 for(int32_t i=0; i<WPNCNT; i++)
1310 reset_weaponname(i);
1311
1312 return ret;
1313 }
1314
1315 bool reset_mapstyles(bool validate, miscQdata *Misc)
1316 {
1317 Misc->colors.blueframe_tile = 20044;
1318 Misc->colors.blueframe_cset = 0;
1319 Misc->colors.triforce_tile = 23461;
1320 Misc->colors.triforce_cset = 1;
1321 Misc->colors.triframe_tile = 18752;
1322 Misc->colors.triframe_cset = 1;
1323 Misc->colors.overworld_map_tile = 16990;
1324 Misc->colors.overworld_map_cset = 2;
1325 Misc->colors.HCpieces_tile = 21160;
1326 Misc->colors.HCpieces_cset = 8;
1327 Misc->colors.dungeon_map_tile = 19651;
1328 Misc->colors.dungeon_map_cset = 8;
1329 return true;
1330 }
1331
1332 39 int32_t get_qst_buffers()
1333 {
1334 39 memrequested+=(sizeof(mapscr)*MAPSCRS);
1335 39 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1336 39 TheMaps.resize(MAPSCRS);
1337
1338
2/2
✓ Branch 0 taken 5304 times.
✓ Branch 1 taken 39 times.
5343 for(int32_t i(0); i<MAPSCRS; i++)
1339 5304 TheMaps[i].zero_memory();
1340
1341 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1342 39 Z_message("OK\n"); // Allocating map buffer...
1343
1344 39 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1345 39 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1346
1347
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1348 return 0;
1349
1350 39 Z_message("OK\n");
1351
1352 // Allocating space for all 65535 strings uses up 10.62MB...
1353 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1354 // (Shoelace's "Hero of Dreams" uses 1415.)
1355 // So let's be a bit generous and allow 4096 initially.
1356 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1357 // I tested it and it worked without flaw on 6/6/11. - L.
1358 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1359 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1360 // See https://discord.com/channels/876899628556091432/992984989073416242
1361 39 msg_strings_size = 8192;
1362 39 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1363 39 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1364
1365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 MsgStrings = new MsgStr[msg_strings_size];
1366
1367 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1368
2/2
✓ Branch 0 taken 319488 times.
✓ Branch 1 taken 39 times.
319527 for(auto q = 0; q < msg_strings_size; ++q)
1369 {
1370 319488 MsgStrings[q].clear();
1371 319488 }
1372 39 Z_message("OK\n"); // Allocating string buffer...
1373
1374 39 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1375 39 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1376
1377
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1378 return 0;
1379
1380 39 Z_message("OK\n"); // Allocating door combo buffer...
1381
1382 39 memrequested+=(sizeof(dmap)*MAXDMAPS);
1383 39 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1384
1385
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1386 return 0;
1387
1388 39 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1389 39 Z_message("OK\n"); // Allocating dmap buffer...
1390
1391 39 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1392 39 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1393
1394 39 combobuf.clear();
1395 39 combobuf.resize(MAXCOMBOS);
1396 39 Z_message("OK\n"); // Allocating combo buffer...
1397
1398 39 memrequested+=(psTOTAL255);
1399 39 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1400
1401
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1402 return 0;
1403
1404 39 Z_message("OK\n"); // Allocating color data buffer...
1405
1406 39 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1407 39 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1408
1409 39 free_newtilebuf();
1410
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1411 return 0;
1412
1413 39 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1414 //Z_message("Performed memset on tiles\n");
1415 39 clear_tiles(newtilebuf);
1416 //Z_message("Performed clear_tiles()\n");
1417 39 Z_message("OK\n"); // Allocating tile buffer...
1418
1419
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(is_zquest())
1420 {
1421 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1422 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1423
1424 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1425 return 0;
1426
1427 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1428 clear_tiles(grabtilebuf);
1429 Z_message("OK\n"); // Allocating tile grab buffer...
1430 }
1431
1432 39 memrequested+=(100000);
1433 39 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1434
1435
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((trashbuf=(byte*)malloc(100000))==NULL)
1436 return 0;
1437
1438 39 Z_message("OK\n"); // Allocating trash buffer...
1439
1440 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1441 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1442 // fixed by ensuring there's actually itemdata there.
1443 // If you change this, be sure to update del_qst_buffers, too.
1444
1445 39 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1446 39 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1447
1448
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1449 return 0;
1450
1451 39 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1452 39 itemsbuf++;
1453 39 Z_message("OK\n"); // Allocating item buffer...
1454
1455 39 memrequested+=(sizeof(wpndata)*MAXWPNS);
1456 39 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1457
1458
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1459 return 0;
1460
1461 39 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1462 39 Z_message("OK\n"); // Allocating weapon buffer...
1463
1464 39 memrequested+=(sizeof(guydata)*MAXGUYS);
1465 39 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1466
1467
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1468 return 0;
1469
1470 39 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1471 39 Z_message("OK\n"); // Allocating guy buffer...
1472
1473 39 memrequested+=(sizeof(comboclass)*cMAX);
1474 39 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1475
1476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1477 return 0;
1478
1479 39 Z_message("OK\n"); // Allocating combo class buffer...
1480
1481 39 return 1;
1482 39 }
1483
1484
1485 39 void free_newtilebuf()
1486 {
1487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(newtilebuf)
1488 {
1489 for(int32_t i=0; i<NEWMAXTILES; i++)
1490 if(newtilebuf[i].data)
1491 free(newtilebuf[i].data);
1492
1493 free(newtilebuf);
1494 newtilebuf = 0;
1495 }
1496 39 }
1497
1498 void free_grabtilebuf()
1499 {
1500 if(is_zquest())
1501 {
1502 if(grabtilebuf)
1503 {
1504 for(int32_t i=0; i<NEWMAXTILES; i++)
1505 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1506
1507 free(grabtilebuf);
1508 grabtilebuf = 0;
1509 }
1510 }
1511 }
1512
1513 void del_qst_buffers()
1514 {
1515 al_trace("Cleaning maps. \n");
1516
1517 if(ZCMaps) free(ZCMaps);
1518
1519 if(MsgStrings) delete[] MsgStrings;
1520
1521 if(DoorComboSets) free(DoorComboSets);
1522
1523 if(DMaps) free(DMaps);
1524
1525 combobuf.clear();
1526
1527 if(colordata) free(colordata);
1528
1529 al_trace("Cleaning tile buffers. \n");
1530 free_newtilebuf();
1531 free_grabtilebuf();
1532
1533 al_trace("Cleaning misc. \n");
1534
1535 if(trashbuf) free(trashbuf);
1536
1537 // See get_qst_buffers
1538 if(itemsbuf)
1539 {
1540 itemsbuf--;
1541 free(itemsbuf);
1542 }
1543
1544 if(wpnsbuf) free(wpnsbuf);
1545
1546 if(guysbuf) free(guysbuf);
1547
1548 if(combo_class_buf) free(combo_class_buf);
1549 }
1550
1551 4 bool init_palnames()
1552 {
1553 // if(palnames==NULL)
1554 // return false;
1555
1556
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1557 {
1558
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1559 {
1560 case 0:
1561 4 sprintf(palnames[x],"Overworld");
1562 4 break;
1563
1564 case 10:
1565 4 sprintf(palnames[x],"Caves");
1566 4 break;
1567
1568 case 11:
1569 4 sprintf(palnames[x],"Passageways");
1570 4 break;
1571
1572 default:
1573 2036 sprintf(palnames[x],"%c",0);
1574 2036 break;
1575 }
1576 2048 }
1577
1578 4 return true;
1579 }
1580
1581 21369 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1582 {
1583 void *p;
1584
1585
1/2
✓ Branch 0 taken 21369 times.
✗ Branch 1 not taken.
21369 p = _AL_MALLOC(MAX(size, alloc_size));
1586
1587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21369 times.
21369 if(!p)
1588 {
1589 return NULL;
1590 }
1591
1592
1/2
✓ Branch 0 taken 21369 times.
✗ Branch 1 not taken.
21369 if(!pfread(p,size,f,keepdata))
1593 {
1594 _AL_FREE(p);
1595 return NULL;
1596 }
1597
1598
1/2
✓ Branch 0 taken 21369 times.
✗ Branch 1 not taken.
21369 if(pack_ferror(f))
1599 {
1600 _AL_FREE(p);
1601 return NULL;
1602 }
1603
1604 21369 return p;
1605 21369 }
1606
1607 /* read_midi:
1608 * Reads MIDI data from a datafile (this is not the same thing as the
1609 * standard midi file format).
1610 */
1611
1612 1876 static MIDI *read_midi(PACKFILE *f, bool)
1613 {
1614 MIDI *m;
1615 int32_t c;
1616 1876 int16_t divisions=0;
1617 1876 int32_t len=0;
1618
1619 1876 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1620
1621
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!m)
1622 {
1623 return NULL;
1624 }
1625
1626
2/2
✓ Branch 0 taken 60032 times.
✓ Branch 1 taken 1876 times.
61908 for(c=0; c<MIDI_TRACKS; c++)
1627 {
1628 60032 m->track[c].len = 0;
1629 60032 m->track[c].data = NULL;
1630 60032 }
1631
1632 1876 p_mgetw(&divisions,f,true);
1633 1876 m->divisions=divisions;
1634
1635
2/2
✓ Branch 0 taken 60032 times.
✓ Branch 1 taken 1876 times.
61908 for(c=0; c<MIDI_TRACKS; c++)
1636 {
1637 60032 p_mgetl(&len,f,true);
1638 60032 m->track[c].len=len;
1639
1640
2/2
✓ Branch 0 taken 38663 times.
✓ Branch 1 taken 21369 times.
60032 if(m->track[c].len > 0)
1641 {
1642 21369 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1643
1644
1/2
✓ Branch 0 taken 21369 times.
✗ Branch 1 not taken.
21369 if(!m->track[c].data)
1645 {
1646 destroy_midi(m);
1647 return NULL;
1648 }
1649 21369 }
1650 60032 }
1651
1652 LOCK_DATA(m, sizeof(MIDI));
1653
1654
2/2
✓ Branch 0 taken 60032 times.
✓ Branch 1 taken 1876 times.
61908 for(c=0; c<MIDI_TRACKS; c++)
1655 {
1656
2/2
✓ Branch 0 taken 21369 times.
✓ Branch 1 taken 38663 times.
60032 if(m->track[c].data)
1657 {
1658 LOCK_DATA(m->track[c].data, m->track[c].len);
1659 21369 }
1660 60032 }
1661
1662 1876 return m;
1663 1876 }
1664
1665 void clear_combo(int32_t i)
1666 {
1667 combobuf[i].clear();
1668 }
1669
1670 void clear_combos()
1671 {
1672 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1673 clear_combo(tmpcounter);
1674 }
1675
1676 void pack_combos()
1677 {
1678 int32_t di = 0;
1679
1680 for(int32_t si=0; si<1024; si+=2)
1681 combobuf[di++] = combobuf[si];
1682
1683 for(; di<1024; di++)
1684 clear_combo(di);
1685 }
1686
1687 115 void reset_tunes(zctune *tune)
1688 {
1689
2/2
✓ Branch 0 taken 28980 times.
✓ Branch 1 taken 115 times.
29095 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1690 {
1691 28980 tune[i].reset();
1692 28980 }
1693 115 }
1694
1695
1696 /*void reset_midi(zcmidi_ *m)
1697 {
1698 m->title[0]=0;
1699 m->loop=1;
1700 m->volume=144;
1701 m->start=0;
1702 m->loop_start=-1;
1703 m->loop_end=-1;
1704 if(m->midi)
1705 {
1706 destroy_midi(m->midi);
1707 }
1708 m->midi=NULL;
1709 }
1710
1711
1712 void reset_midis(zcmidi_ *m)
1713 {
1714 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1715 {
1716 reset_midi(m+i);
1717 }
1718 }
1719 */
1720
1721 void reset_scr(int32_t scr)
1722 {
1723 /*
1724 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1725 for(unsigned i=0; i<sizeof(mapscr); i++)
1726 *(di++) = 0;
1727 TheMaps[scr].valid=mVERSION;
1728 */
1729
1730 TheMaps[scr].zero_memory();
1731 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1732
1733 for(int32_t i=0; i<6; i++)
1734 {
1735 //these will be uncommented later
1736 //TheMaps[scr].layerxsize[i]=16;
1737 //TheMaps[scr].layerysize[i]=11;
1738 TheMaps[scr].layeropacity[i]=255;
1739 }
1740
1741 TheMaps[scr].valid=mVERSION;
1742
1743 }
1744
1745 /* For reference:
1746
1747 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1748 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1749 */
1750
1751 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1752 {
1753
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1754 {
1755
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1756 {
1757
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1758 {
1759
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1760 {
1761 1968 return false;
1762 }
1763
1764
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1765 {
1766 return false;
1767 }
1768
1769
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1770 {
1771 return false;
1772 }
1773
1774
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1775 {
1776 return false;
1777 }
1778 58104 }
1779
1780
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1781 {
1782 return false;
1783 }
1784
1785
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1786 {
1787 return false;
1788 }
1789
1790
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1791 {
1792 return false;
1793 }
1794
1795
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1796 {
1797 return false;
1798 }
1799 87156 }
1800
1801
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1802 {
1803
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1804 {
1805 return false;
1806 }
1807
1808
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1809 {
1810 return false;
1811 }
1812
1813
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1814 {
1815 return false;
1816 }
1817
1818
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1819 {
1820 return false;
1821 }
1822
1823
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1824 {
1825 return false;
1826 }
1827 3228 }
1828
1829
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1830 {
1831
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1832 {
1833 return false;
1834 }
1835
1836
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1837 {
1838 return false;
1839 }
1840
1841
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1842 {
1843 return false;
1844 }
1845
1846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1847 {
1848 return false;
1849 }
1850 4842 }
1851
1852
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1853 {
1854 return false;
1855 }
1856
1857
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1858 {
1859 return false;
1860 }
1861 14526 }
1862
1863 1614 return true;
1864 3582 }
1865
1866 int32_t doortranslations_u[9][4]=
1867 {
1868 {37,38,53,54},
1869 {37,38,39,40},
1870 {37,38,55,56},
1871 {37,38,39,40},
1872 {37,38,53,54},
1873 {37,38,53,54},
1874 {37,38,53,54},
1875 {7,8,23,24},
1876 {7,8,41,42}
1877 };
1878
1879 int32_t doortranslations_d[9][4]=
1880 {
1881 {117,118,133,134},
1882 {135,136,133,134},
1883 {119,120,133,134},
1884 {135,136,133,134},
1885 {117,118,133,134},
1886 {117,118,133,134},
1887 {117,118,133,134},
1888 {151,152,167,168},
1889 {137,138,167,168},
1890 };
1891
1892 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1893 int32_t doortranslations_l[9][6]=
1894 {
1895 {66,67,82,83,98,99},
1896 {66,68,82,84,98,100},
1897 {66,69,82,85,98,101},
1898 {66,68,82,84,98,100},
1899 {66,67,82,83,98,99},
1900 {66,67,82,83,98,99},
1901 {66,67,82,83,98,99},
1902 {64,65,80,81,96,97},
1903 {64,65,80,114,96,97},
1904 };
1905
1906 int32_t doortranslations_r[9][6]=
1907 {
1908
1909 {76,77,92,93,108,109},
1910 {75,77,91,93,107,109},
1911 {74,77,90,93,106,109},
1912 {75,77,91,93,107,109},
1913 {76,77,92,93,108,109},
1914 {76,77,92,93,108,109},
1915 {76,77,92,93,108,109},
1916 {78,79,94,95,110,111},
1917 {78,79,125,95,110,111},
1918 };
1919
1920 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1921 {
1922 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1923 }
1924
1925 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1926 {
1927 //these are here to bypass compiler warnings about unused arguments
1928 308180 map=map;
1929 308180 scr=scr;
1930 308180 pos=pos;
1931
1932 //what does this function do?
1933 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1934 308180 return 2;
1935 }
1936
1937 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1938 {
1939
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1940 {
1941 5450 return 0;
1942 }
1943
1944 DoorComboSet tempdcs;
1945 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1946
1947 //up
1948
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1949 {
1950
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1951 {
1952 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1953 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1954 58392 }
1955 14598 }
1956
1957 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1958 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1959 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1960 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1961 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1962 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1963
1964 //down
1965
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1966 {
1967
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1968 {
1969 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1970 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1971 58392 }
1972 14598 }
1973
1974 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1975
1976 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1977 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1978 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1979 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1980 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1981
1982 //left
1983 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1984
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1985 {
1986
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1987 {
1988 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1989 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1990 87588 }
1991 14598 }
1992
1993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1994 {
1995 if((j!=2)&&(j!=3))
1996 {
1997 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1998 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1999 }
2000 }
2001
2002 1622 tempdcs.bombdoorcombo_l[0]=0;
2003 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2004 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2005 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2006 1622 tempdcs.bombdoorcombo_l[2]=0;
2007 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2009 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2010
2011 //right
2012
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2013 {
2014
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2015 {
2016 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2017 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2018 87588 }
2019 14598 }
2020
2021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2022 {
2023 if((j!=2)&&(j!=3))
2024 {
2025 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2026 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2027 }
2028 }
2029
2030 1622 tempdcs.bombdoorcombo_r[0]=0;
2031 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2032 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2033 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2034 1622 tempdcs.bombdoorcombo_r[2]=0;
2035 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2037 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2038
2039 int32_t k;
2040
2041
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2042 {
2043
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2044 {
2045 1614 break;
2046 }
2047 1968 }
2048
2049
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2050 {
2051 8 DoorComboSets[k]=tempdcs;
2052 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2053 8 ++door_combo_set_count;
2054 8 }
2055
2056 1622 return k;
2057 /*
2058 doorcombo_u[9][4];
2059 doorcset_u[9][4];
2060 doorcombo_d[9][4];
2061 doorcset_d[9][4];
2062 doorcombo_l[9][6];
2063 doorcset_l[9][6];
2064 doorcombo_r[9][6];
2065 doorcset_r[9][6];
2066 bombdoorcombo_u[2];
2067 bombdoorcset_u[2];
2068 bombdoorcombo_d[2];
2069 bombdoorcset_d[2];
2070 bombdoorcombo_l[3];
2071 bombdoorcset_l[3];
2072 bombdoorcombo_r[3];
2073 bombdoorcset_r[3];
2074 walkthroughcombo[4];
2075 walkthroughcset[4];
2076 */
2077 7072 }
2078
2079 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2080 {
2081 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2082 }
2083
2084 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2085 {
2086
2087 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2088 }
2089
2090 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2091 {
2092 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2093 }
2094
2095
2096 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2097 {
2098 char temp_pwd[30];
2099 9 memset(temp_pwd,0,30);
2100
2101
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2102 {
2103 9 memcpy(temp_pwd,encrypted_pwd,30);
2104 9 temp_pwd[29]=0;
2105
2106
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2107 {
2108 270 temp_pwd[i] -= pwdkey;
2109 270 int32_t t=pwdkey>>15;
2110 270 pwdkey = (pwdkey<<1)+t;
2111 270 }
2112 9 }
2113
2114 9 memcpy(pwd,temp_pwd,30);
2115 9 }
2116
2117
2118 85 bool devpwd()
2119 {
2120 #ifdef _DEBUG
2121 return true;
2122 #endif
2123 85 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2124 }
2125 bool check_questpwd(zquestheader *Header, char *pwd)
2126 {
2127 #if DEVLEVEL > 3
2128 return true;
2129 #endif
2130
2131 if (devpwd()) return true;
2132 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2133 cvs_MD5Context ctx;
2134 uint8_t md5sum[16];
2135
2136 cvs_MD5Init(&ctx);
2137 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2138 cvs_MD5Final(md5sum, &ctx);
2139
2140 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2141 }
2142
2143 107 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2144 {
2145 107 zprint2("\n");
2146 107 zprint2("[ZQUEST CREATOR METADATA]\n");
2147
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(qst_num < moduledata.max_quest_files)
2148 zprint2("Loading module quest %d\n", qst_num+1);
2149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(path) zprint2("Loading '%s'\n", path);
2150
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 4 times.
107 if ( tempheader.new_version_id_main > 0 )
2151 {
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(tempheader.new_version_id_fourth > 0)
2153 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2154 tempheader.new_version_id_main,tempheader.new_version_id_second,
2155 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2156 103 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2157 103 tempheader.new_version_id_main,tempheader.new_version_id_second,
2158 103 tempheader.new_version_id_third);
2159 103 }
2160 else
2161 {
2162
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2163 {
2164 case 0x255:
2165 {
2166 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2167 break;
2168 }
2169 case 0x254:
2170 {
2171 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2172 break;
2173 }
2174 case 0x250:
2175 {
2176 switch(tempheader.build)
2177 {
2178 case 19:
2179 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2180 case 20:
2181 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2182 case 21:
2183 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2184 case 22:
2185 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2186 case 23:
2187 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2188 case 24:
2189 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2190 case 25:
2191 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2192 case 26:
2193 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2194 case 27:
2195 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2196 case 28:
2197 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2198 case 29:
2199 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2200 case 30:
2201 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2202 case 31:
2203 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2204 case 32:
2205 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2206 case 33:
2207 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2208 default:
2209 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2210
2211 }
2212 break;
2213 }
2214
2215 case 0x211:
2216 {
2217 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2218 }
2219 case 0x210:
2220 {
2221 zprint2("Last saved in ZQuest Version: 2.10.x");
2222 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2223 break;
2224 }
2225 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2226 case 0x193:
2227 {
2228 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2229 }
2230 case 0x192:
2231 {
2232 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2233 }
2234 case 0x190:
2235 {
2236 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2237 }
2238 case 0x184:
2239 {
2240 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2241 }
2242 case 0x183:
2243 {
2244 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2245 }
2246 case 0x180:
2247 {
2248 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2249 }
2250 default:
2251 {
2252 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2253 }
2254 */
2255 }
2256 }
2257
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
107 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2258 22 zprint2("%s\n", tempheader.getAlphaVerStr());
2259 85 else zprint2("\n");
2260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 22 times.
107 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2261
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 22 times.
107 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2262
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 22 times.
107 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2263
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 22 times.
107 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2264
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 103 times.
107 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2265
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 22 times.
107 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2266 107 zprint2("\n");
2267 107 }
2268
2269 115 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2270 {
2271 int32_t dummy;
2272 zquestheader tempheader;
2273 char dummybuf[80];
2274 byte temp_map_count;
2275 byte temp_midi_flags[MIDIFLAGS_SIZE];
2276 word version;
2277 char temp_pwd[30], temp_pwd2[30];
2278 int16_t temp_pwdkey;
2279 cvs_MD5Context ctx;
2280 115 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2281 115 memset(&tempheader, 0, sizeof(tempheader));
2282 115 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2283
2284
2285
2286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2287 {
2288 Z_message("Unable to read header string\n");
2289 return qe_invalid;
2290 }
2291
2292 // check header
2293
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2294 {
2295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2296 {
2297 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2298 return qe_invalid;
2299 }
2300 4 }
2301
2302 115 int32_t templatepath_len=0;
2303
2304 115 tempheader.external_zinfo = false;
2305 115 read_zinfo = false;
2306
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2307 {
2308 byte padding;
2309
2310
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2321
2322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2323 {
2324 return qe_version;
2325 }
2326
2327 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2328
2329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2330 {
2331 return qe_invalid;
2332 }
2333
2334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2335 {
2336 return qe_obsolete;
2337 }
2338
2339
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2345 {
2346 return qe_invalid;
2347 }
2348
2349 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2350
2351
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2352 {
2353 return qe_invalid;
2354 }
2355
2356
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2357 {
2358 return qe_invalid;
2359 }
2360
2361 4 FFCore.quest_format[qMapCount] = temp_map_count;
2362
2363
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2364 {
2365 return qe_invalid;
2366 }
2367
2368
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2374 {
2375 return qe_invalid;
2376 }
2377
2378
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2379 {
2380 return qe_invalid;
2381 }
2382
2383
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2384 {
2385 return qe_invalid;
2386 }
2387
2388
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2389 {
2390 return qe_invalid;
2391 }
2392
2393
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2394 {
2395 return qe_invalid;
2396 }
2397
2398
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2399 {
2400 return qe_invalid;
2401 }
2402
2403
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2404 {
2405 return qe_invalid;
2406 }
2407 // These fields are expected to end in null bytes!
2408 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2409
2410
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2411 {
2412 return qe_invalid;
2413 }
2414 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2415
2416
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2417 {
2418 return qe_invalid;
2419 }
2420
2421
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2422 {
2423 return qe_invalid;
2424 }
2425
2426
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2427 {
2428 return qe_invalid;
2429 }
2430
2431 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2432 4 cvs_MD5Init(&ctx);
2433 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2434 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2435
2436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2437 {
2438 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2439 // Not anymore...
2440 memset(tempheader.minver,0,17);
2441 tempheader.build=0;
2442 tempheader.use_keyfile=0;
2443 memset(tempheader.old_foo, 0, 9);
2444 }
2445 else
2446 {
2447
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2448 {
2449 return qe_invalid;
2450 }
2451
2452
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2453 {
2454 return qe_invalid;
2455 }
2456
2457 4 FFCore.quest_format[vBuild] = tempheader.build;
2458
2459
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2460 {
2461 return qe_invalid;
2462 }
2463
2464
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2465 {
2466 return qe_invalid;
2467 }
2468 } // starting at minver
2469
2470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2471 {
2472 memset(&quest_rules[4],0,16); // word rules3..rules10
2473 }
2474 else
2475 {
2476
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2477 {
2478 return qe_invalid; // starting at rules3
2479 }
2480
2481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2482 {
2483 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2484 4 }
2485 }
2486
2487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2488 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2489 {
2490 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2491 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2492 4 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,1);
2493 4 }
2494
2495
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2496 {
2497 byte *mf=temp_midi_flags;
2498
2499 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2500 {
2501 mf=(byte*)dummybuf;
2502 }
2503
2504 if(!pfread(mf,32,f,true)) // read new header additions
2505 {
2506 return qe_invalid; // starting at foo2
2507 }
2508
2509 if(!pfread(dummybuf,18,f,true)) // read new header additions
2510 {
2511 return qe_invalid; // starting at foo2
2512 }
2513 }
2514
2515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2516 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2517 {
2518 4 memset(tempheader.templatepath,0,2048);
2519 4 }
2520 else
2521 {
2522 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2523 {
2524 return qe_invalid;
2525 }
2526 }
2527
2528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2529 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2530 {
2531 4 tempheader.use_keyfile=0;
2532 4 }
2533 4 }
2534 else
2535 {
2536 //section id
2537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_mgetl(&dummy,f,true))
2538 {
2539 return qe_invalid;
2540 }
2541
2542 //section version info
2543
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&version,f,true))
2544 {
2545 return qe_invalid;
2546 }
2547
2548 111 FFCore.quest_format[vHeader] = version;
2549
2550
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy,f,true))
2551 {
2552 return qe_invalid;
2553 }
2554
2555 //section size
2556
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
2557 {
2558 return qe_invalid;
2559 }
2560
2561 //finally... section data
2562
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&tempheader.zelda_version,f,true))
2563 {
2564 return qe_invalid;
2565 }
2566
2567 111 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2568
2569 //do some quick checking...
2570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(tempheader.zelda_version > ZELDA_VERSION)
2571 {
2572 return qe_version;
2573 }
2574
2575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2576 {
2577 return qe_invalid;
2578 }
2579
2580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(bad_version(tempheader.zelda_version))
2581 {
2582 return qe_obsolete;
2583 }
2584
2585
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&tempheader.build,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
2590 111 FFCore.quest_format[vBuild] = tempheader.build;
2591
2592
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(version<3)
2593 {
2594
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2595 {
2596 return qe_invalid;
2597 }
2598
2599
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2600 {
2601 return qe_invalid;
2602 }
2603
2604 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2605 5 cvs_MD5Init(&ctx);
2606 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2607 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2608 5 }
2609 else
2610 {
2611
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2612 {
2613 return qe_invalid;
2614 }
2615 }
2616
2617
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&tempheader.internal,f,true))
2618 {
2619 return qe_invalid;
2620 }
2621
2622
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&tempheader.quest_number,f,true))
2623 {
2624 return qe_invalid;
2625 }
2626
2627 111 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2628
2629 111 size_t versz = version < 8 ? 9 : 16;
2630
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(tempheader.version,versz,f,true))
2631 {
2632 return qe_invalid;
2633 }
2634
2635 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2636 //needs to be copied as char[9] or stored as a s.str
2637
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(tempheader.minver,versz,f,true))
2638 {
2639 return qe_invalid;
2640 }
2641
2642 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2643
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2644 {
2645 return qe_invalid;
2646 }
2647 111 tempheader.title[sizeof(tempheader.title)-1] = 0;
2648
2649
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2650 {
2651 return qe_invalid;
2652 }
2653 111 tempheader.author[sizeof(tempheader.author)-1] = 0;
2654
2655
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&tempheader.use_keyfile,f,true))
2656 {
2657 return qe_invalid;
2658 }
2659
2660 /*
2661 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2662 {
2663 return qe_invalid;
2664 }
2665 */
2666
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2667 {
2668 return qe_invalid;
2669 }
2670
2671
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(&dummybuf,4,f,true))
2672 {
2673 return qe_invalid;
2674 }
2675
2676
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2677 {
2678 return qe_invalid;
2679 }
2680
2681
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(dummybuf,14,f,true))
2682 {
2683 return qe_invalid;
2684 }
2685
2686 111 templatepath_len=sizeof(tempheader.templatepath);
2687
2688
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(version==1)
2689 {
2690 5 templatepath_len=280;
2691 5 }
2692
2693
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2694 {
2695 return qe_invalid;
2696 }
2697
2698
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&temp_map_count,f,true))
2699 {
2700 return qe_invalid;
2701 }
2702
2703
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(version>=4)
2704 {
2705
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2706 {
2707 return qe_invalid;
2708 }
2709
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2710 {
2711 return qe_invalid;
2712 }
2713
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2714 {
2715 return qe_invalid;
2716 }
2717
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2718 {
2719 return qe_invalid;
2720 }
2721
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2722 {
2723 return qe_invalid;
2724 }
2725
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2726 {
2727 return qe_invalid;
2728 }
2729
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2730 {
2731 return qe_invalid;
2732 }
2733
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2734 {
2735 return qe_invalid;
2736 }
2737
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2738 {
2739 return qe_invalid;
2740 }
2741
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2742 {
2743 return qe_invalid;
2744 }
2745
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2746 {
2747 return qe_invalid;
2748 }
2749
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2750 {
2751 return qe_invalid;
2752 }
2753
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2754 {
2755 return qe_invalid;
2756 }
2757
2758
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_devsig,256,f,true))
2759 {
2760 return qe_invalid;
2761 }
2762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2763 strcpy(tempheader.new_version_devsig, "EmilyV99");
2764
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_compilername,256,f,true))
2765 {
2766 return qe_invalid;
2767 }
2768
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2769 {
2770 return qe_invalid;
2771 }
2772
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.product_name,1024,f,true))
2773 {
2774 return qe_invalid;
2775 }
2776
2777
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&tempheader.compilerid,f,true))
2778 {
2779 return qe_invalid;
2780 }
2781
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2782 {
2783 return qe_invalid;
2784 }
2785
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2786 {
2787 return qe_invalid;
2788 }
2789
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2790 {
2791 return qe_invalid;
2792 }
2793
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2794 {
2795 return qe_invalid;
2796 }
2797
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&tempheader.developerid,f,true))
2798 {
2799 return qe_invalid;
2800 }
2801
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2802 {
2803 return qe_invalid;
2804 }
2805
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.build_datestamp,256,f,true))
2806 {
2807 return qe_invalid;
2808 }
2809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!pfread(tempheader.build_timestamp,256,f,true))
2810 {
2811 return qe_invalid;
2812 }
2813 30 }
2814 else // <4
2815 {
2816 81 tempheader.new_version_id_main = 0;
2817 81 tempheader.new_version_id_second = 0;
2818 81 tempheader.new_version_id_third = 0;
2819 81 tempheader.new_version_id_fourth = 0;
2820 81 tempheader.new_version_id_alpha = 0;
2821 81 tempheader.new_version_id_beta = 0;
2822 81 tempheader.new_version_id_gamma = 0;
2823 81 tempheader.new_version_id_release = 0;
2824 81 tempheader.new_version_id_date_year = 0;
2825 81 tempheader.new_version_id_date_month = 0;
2826 81 tempheader.new_version_id_date_day = 0;
2827 81 tempheader.new_version_id_date_hour = 0;
2828 81 tempheader.new_version_id_date_minute = 0;
2829
2830 81 memset(tempheader.new_version_devsig, 0, 256);
2831 81 memset(tempheader.new_version_compilername, 0, 256);
2832 81 memset(tempheader.new_version_compilerversion, 0, 256);
2833 81 memset(tempheader.product_name, 0, 1024);
2834 81 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2835
2836 81 tempheader.compilerid = 0;
2837 81 tempheader.compilerversionnumber_first = 0;
2838 81 tempheader.compilerversionnumber_second = 0;
2839 81 tempheader.compilerversionnumber_third = 0;
2840 81 tempheader.compilerversionnumber_fourth = 0;
2841 81 tempheader.developerid = 0;
2842
2843 81 memset(tempheader.made_in_module_name, 0, 1024);
2844 81 memset(tempheader.build_datestamp, 0, 256);
2845 81 memset(tempheader.build_timestamp, 0, 256);
2846 }
2847
2848
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if ( version >= 5 )
2849 {
2850
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!pfread(tempheader.build_timezone,6,f,true))
2851 {
2852 return qe_invalid;
2853 }
2854 30 }
2855 else // < 5
2856 {
2857 81 memset(tempheader.build_timezone, 0, 6);
2858 }
2859
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if ( version >= 6 )
2860 {
2861 byte b;
2862
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&b,f,true))
2863 {
2864 return qe_invalid;
2865 }
2866 30 tempheader.external_zinfo = b?true:false;
2867 30 read_zinfo = true;
2868 30 }
2869
2870
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(version >= 7)
2871 {
2872
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2873 {
2874 return qe_invalid;
2875 }
2876 30 }
2877 else
2878 {
2879 81 tempheader.new_version_is_nightly = false;
2880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(tempheader.zelda_version < 0x255)
2881 {
2882
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
81 switch(tempheader.zelda_version)
2883 {
2884 case 0x254:
2885 tempheader.new_version_id_main = 2;
2886 tempheader.new_version_id_second = 54;
2887 break;
2888 case 0x250:
2889
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 1 times.
76 switch(tempheader.build)
2890 {
2891 case 19:
2892 tempheader.new_version_id_main = 2;
2893 tempheader.new_version_id_second = 50;
2894 tempheader.new_version_id_gamma = 1;
2895 break;
2896 case 20:
2897 tempheader.new_version_id_main = 2;
2898 tempheader.new_version_id_second = 50;
2899 tempheader.new_version_id_gamma = 2;
2900 break;
2901 case 21:
2902 tempheader.new_version_id_main = 2;
2903 tempheader.new_version_id_second = 50;
2904 tempheader.new_version_id_gamma = 3;
2905 break;
2906 case 22:
2907 tempheader.new_version_id_main = 2;
2908 tempheader.new_version_id_second = 50;
2909 tempheader.new_version_id_gamma = 4;
2910 break;
2911 case 23:
2912 tempheader.new_version_id_main = 2;
2913 tempheader.new_version_id_second = 50;
2914 tempheader.new_version_id_gamma = 5;
2915 break;
2916 case 24:
2917 22 tempheader.new_version_id_main = 2;
2918 22 tempheader.new_version_id_second = 50;
2919 22 tempheader.new_version_id_release = -1;
2920 22 break;
2921 case 25:
2922 tempheader.new_version_id_main = 2;
2923 tempheader.new_version_id_second = 50;
2924 tempheader.new_version_id_third = 1;
2925 tempheader.new_version_id_gamma = 1;
2926 break;
2927 case 26:
2928 tempheader.new_version_id_main = 2;
2929 tempheader.new_version_id_second = 50;
2930 tempheader.new_version_id_third = 1;
2931 tempheader.new_version_id_gamma = 2;
2932 break;
2933 case 27:
2934 tempheader.new_version_id_main = 2;
2935 tempheader.new_version_id_second = 50;
2936 tempheader.new_version_id_third = 1;
2937 tempheader.new_version_id_gamma = 3;
2938 break;
2939 case 28:
2940 5 tempheader.new_version_id_main = 2;
2941 5 tempheader.new_version_id_second = 50;
2942 5 tempheader.new_version_id_third = 1;
2943 5 tempheader.new_version_id_release = -1;
2944 5 break;
2945 case 29:
2946 24 tempheader.new_version_id_main = 2;
2947 24 tempheader.new_version_id_second = 50;
2948 24 tempheader.new_version_id_third = 2;
2949 24 tempheader.new_version_id_release = -1;
2950 24 break;
2951 case 30:
2952 tempheader.new_version_id_main = 2;
2953 tempheader.new_version_id_second = 50;
2954 tempheader.new_version_id_third = 3;
2955 tempheader.new_version_id_gamma = 1;
2956 break;
2957 case 31:
2958 15 tempheader.new_version_id_main = 2;
2959 15 tempheader.new_version_id_second = 53;
2960 15 tempheader.new_version_id_gamma = -1;
2961 15 break;
2962 case 32:
2963 9 tempheader.new_version_id_main = 2;
2964 9 tempheader.new_version_id_second = 53;
2965 9 tempheader.new_version_id_release = -1;
2966 9 break;
2967 case 33:
2968 1 tempheader.new_version_id_main = 2;
2969 1 tempheader.new_version_id_second = 53;
2970 1 tempheader.new_version_id_third = 1;
2971 1 break;
2972 }
2973 76 break;
2974
2975 case 0x211:
2976 tempheader.new_version_id_main = 2;
2977 tempheader.new_version_id_second = 11;
2978 tempheader.new_version_id_beta = tempheader.build;
2979 break;
2980 case 0x210:
2981 5 tempheader.new_version_id_main = 2;
2982 5 tempheader.new_version_id_second = 10;
2983 5 tempheader.new_version_id_beta = tempheader.build;
2984 5 break;
2985 }
2986 81 }
2987 }
2988
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 if(printmetadata || __isZQuest)
2989 {
2990 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2991 }
2992 }
2993
2994 //{ Version Warning
2995 115 int32_t vercmp = tempheader.compareVer();
2996 115 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2997 115 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2998
4/6
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
145 if(vercmp > 0 || (!vercmp &&
2999
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 (astatecmp > 0 || (!astatecmp &&
3000 30 avercmp > 0))))
3001 {
3002 bool r = true;
3003 if(loadquest_report)
3004 {
3005 enter_sys_pal();
3006 AlertDialog("Quest saved in newer version",
3007 "This quest was last saved in a newer version of ZQuest."
3008 " Attempting to load this quest may not work correctly; to"
3009 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3010 "\n\nWould you like to continue loading anyway? (Not recommended)",
3011 [&](bool ret,bool)
3012 {
3013 r = ret;
3014 }).show();
3015 exit_sys_pal();
3016 }
3017 if(!r)
3018 return qe_silenterr;
3019 }
3020
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 else if(tempheader.compareDate() > 0)
3021 {
3022 bool r = true;
3023 if(loadquest_report)
3024 {
3025 enter_sys_pal();
3026 AlertDialog("Quest saved in newer build",
3027 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3028 " issues loading in this build."
3029 "\n{}"
3030 "\n\nWould you like to continue loading anyway?",
3031 tempheader.getVerCmpStr()),
3032 [&](bool ret,bool)
3033 {
3034 r = ret;
3035 }).show();
3036 exit_sys_pal();
3037 }
3038 if(!r)
3039 return qe_silenterr;
3040 }
3041 //}
3042
3043 115 read_ext_zinfo = tempheader.external_zinfo;
3044
3045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
3046 {
3047 115 memcpy(Header, &tempheader, sizeof(tempheader));
3048 115 map_count=temp_map_count;
3049 115 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3050 115 }
3051
3052 115 return 0;
3053 115 }
3054
3055 117 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3056 {
3057 int32_t dummy;
3058 zquestheader tempheader;
3059 117 word s_version=0;
3060 117 dword compatrule_version=0;
3061
3062 117 memcpy(&tempheader, Header, sizeof(tempheader));
3063
3064
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 111 times.
117 if(tempheader.zelda_version >= 0x193)
3065 {
3066 //section version info
3067
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
3068 {
3069 return qe_invalid;
3070 }
3071
3072 111 FFCore.quest_format[vRules] = s_version;
3073
3074
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy,f,true))
3075 {
3076 return qe_invalid;
3077 }
3078
3079
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if(s_version > 16)
3080 {
3081
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&compatrule_version,f,true))
3082 {
3083 return qe_invalid;
3084 }
3085 30 }
3086 111 FFCore.quest_format[vCompatRule] = compatrule_version;
3087
3088 //section size
3089
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
3090 {
3091 return qe_invalid;
3092 }
3093
3094
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if ( s_version < 15 )
3095 {
3096 //finally... section data
3097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3098 {
3099 return qe_invalid;
3100 }
3101 81 }
3102 else
3103 {
3104
3105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3106 {
3107 return qe_invalid;
3108 }
3109
3110 }
3111 111 }
3112
3113 //al_trace("Rules version %d\n", s_version);
3114 //{ bunch of compat stuff
3115 117 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3116
3117
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 9 times.
117 if(s_version<2)
3118 {
3119 9 set_bit(quest_rules,14,0);
3120 9 set_bit(quest_rules,27,0);
3121 9 set_bit(quest_rules,28,0);
3122 9 set_bit(quest_rules,29,0);
3123 9 set_bit(quest_rules,30,0);
3124 9 set_bit(quest_rules,32,0);
3125 9 set_bit(quest_rules,36,0);
3126 9 set_bit(quest_rules,49,0);
3127 9 set_bit(quest_rules,50,0);
3128 9 set_bit(quest_rules,51,0);
3129 9 set_bit(quest_rules,68,0);
3130 9 set_bit(quest_rules,75,0);
3131 9 set_bit(quest_rules,76,0);
3132 9 set_bit(quest_rules,98,0);
3133 9 set_bit(quest_rules,110,0);
3134 9 set_bit(quest_rules,113,0);
3135 9 set_bit(quest_rules,116,0);
3136 9 set_bit(quest_rules,102,0);
3137 9 set_bit(quest_rules,132,0);
3138 9 }
3139
3140 //Now, do any updates...
3141
5/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3142 {
3143 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3144 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3145 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3146 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3147 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3148 13 }
3149
3150
5/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3151 {
3152 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3153 8 }
3154
3155
5/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3156 {
3157 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3158 8 }
3159
3160
5/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3161 {
3162 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3163 8 }
3164
3165
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 9 times.
117 if(tempheader.zelda_version <= 0x210)
3166 {
3167 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3168 9 }
3169
3170
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 5 times.
117 if(tempheader.zelda_version == 0x210)
3171 {
3172 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3173 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3174 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3175 5 }
3176
3177
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 9 times.
117 if(tempheader.zelda_version <= 0x210)
3178 {
3179 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3180 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3181 9 }
3182
3183 //might not be correct
3184
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if(tempheader.zelda_version < 0x210)
3185 {
3186 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3187 4 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,1);
3188 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3189 4 }
3190
3191
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 9 times.
117 if(tempheader.zelda_version < 0x211)
3192 {
3193 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3194 9 }
3195
3196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
117 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3197 {
3198 set_bit(quest_rules, qr_192b163_WARP,1);
3199 }
3200
3201
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 5 times.
117 if(tempheader.zelda_version == 0x210)
3202 {
3203 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3204 5 set_bit(quest_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3205 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3206 5 }
3207
3208
5/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3209 {
3210 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3211 13 }
3212
3213
5/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
117 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3214 {
3215 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3216 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3217 13 }
3218
3219
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 9 times.
117 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3220 {
3221 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3222 9 }
3223
3224
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 22 times.
117 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3225 {
3226 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3227 22 }
3228
3229
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
117 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3230 {
3231 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3232 13 }
3233
3234
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
117 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3235 {
3236 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3237 13 }
3238
3239
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
117 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3240 {
3241 35 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3242 35 }
3243
3244
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
117 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3245 {
3246 35 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3247 35 }
3248
3249 //Bombchu fix.
3250
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 76 times.
117 if(tempheader.zelda_version == 0x250)
3251 {
3252
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 22 times.
76 if ( tempheader.build == 24 ) //2.50.0
3253 {
3254 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3255 22 }
3256
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 5 times.
76 if ( tempheader.build == 28 ) //2.50.1
3257 {
3258 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3259 5 }
3260
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
76 if ( tempheader.build == 29 ) //2.50.2
3261 {
3262 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3263 24 }
3264
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( tempheader.build == 30 ) //2.50.3RC1
3265 {
3266 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3267 }
3268 76 }
3269
3270
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 51 times.
117 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3271 {
3272 // qr_OFFSETEWPNCOLLISIONFIX
3273 // All 'official' quests need this disabled.
3274 // All 2.10 and lower quests need this enabled to preseve compatability.
3275 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3276
3277 //~Gleeok
3278 36 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3279
3280 // Broke in build 695
3281
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
36 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3282 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3283 36 }
3284
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if (tempheader.zelda_version <= 0x190)
3285 {
3286 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3287 4 }
3288
9/10
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 30 times.
117 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3289 {
3290 86 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3291 86 }
3292
3293
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3294 {
3295 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3296 9 }
3297
3298
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3299 {
3300 85 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3301 85 }
3302
3303
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if ( tempheader.zelda_version < 0x250 )
3304 {
3305 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3306 9 }
3307
3308
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version < 3)
3309 {
3310 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3311 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3312 9 }
3313
3314
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<4)
3315 {
3316 9 set_bit(quest_rules,10,0);
3317 9 }
3318
3319
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<5)
3320 {
3321 9 set_bit(quest_rules,27,0);
3322 9 }
3323
3324
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<6)
3325 {
3326 9 set_bit(quest_rules,46,0);
3327 9 }
3328
3329
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<7) // January 2008
3330 {
3331 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3332 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3333 9 }
3334
3335
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 if(s_version<8)
3336 {
3337 9 set_bit(quest_rules, 12, 0);
3338 9 }
3339 else
3340 {
3341 106 set_bit(deprecated_rules, 12, 0);
3342 }
3343
3344
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<9) // October 2008
3345 {
3346 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3347 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3348 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3349 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3350 9 }
3351
3352
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<10) // December 2008
3353 {
3354 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3355 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3356 9 }
3357
3358
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<11) // April 2009
3359 {
3360 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3361 9 }
3362
3363 // This served no purpose.
3364 // if(s_version<12) // December 2009
3365 // {
3366 // set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3367 // set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3368 // }
3369
3370 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3371
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version < 13)
3372 {
3373 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3374 9 }
3375
3376 // Not entirely sure this is the best place for this...
3377 //2.50.2 bitmap offset fix
3378 115 memset(extra_rules, 0, EXTRARULES_SIZE);
3379
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 49 times.
115 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3380 {
3381 36 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3382 36 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3383 36 }
3384 //required because quest templates also used this bit, although
3385 //it never did anything, before. -Z
3386
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 76 times.
115 if ( tempheader.zelda_version == 0x250 )
3387 {
3388
5/6
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 37 times.
76 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3389 {
3390 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3391 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3392 39 }
3393 76 }
3394
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if ( tempheader.zelda_version == 0x254 )
3395 {
3396 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3397 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3398 }
3399
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
115 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3400 {
3401 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3402 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3403 }
3404 //optimise fast drawing for older versions.
3405
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3406 {
3407 85 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3408 85 }
3409 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3410 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3411 //older quests can set the rule by hand. We need a new qst.dat again.
3412
4/6
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3413 {
3414 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3415 }
3416
4/6
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3417 {
3418 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3419 }
3420
4/6
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3421 {
3422 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3423 }
3424
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if ( tempheader.zelda_version < 0x254 )
3425 {
3426 85 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3427 85 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3428 85 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3429 85 }
3430
3431 //item scripts continue to run
3432
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3433 {
3434 85 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3435 85 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3436 85 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3437 85 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3438 85 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3439 85 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3440 85 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3441 85 }
3442
3443
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3444 {
3445 85 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3446 85 }
3447
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3448 {
3449 85 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3450 85 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3451 85 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3452 85 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3453 85 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3454 85 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3455 85 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3456 85 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3457
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 2 times.
85 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3458 {
3459 2 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3460 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3461 //Now they **do**, unless you disable that behaviour.
3462 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3463 //now enable the disable L/R item swap on load.
3464 2 }
3465
3466 85 }
3467
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3468 {
3469 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3470 85 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3471 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3472 //animations ending earlier than they should.
3473 85 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3474 //Enemies would ignore solidity on the top half of combos
3475 85 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3476 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3477 85 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3478 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3479 85 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3480 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3481 85 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3482 85 }
3483
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if ( tempheader.zelda_version < 0x255 )
3484 {
3485 85 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3486 85 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3487 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3488 85 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3489 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3490 85 }
3491
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3492 {
3493 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3494 85 }
3495
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3496 {
3497 85 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3498 85 }
3499
3500
3501
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3502 {
3503 85 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3504 85 }
3505
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3506 {
3507 85 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3508 85 }
3509
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3510 {
3511 85 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3512 85 }
3513
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3514 {
3515 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3516
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3517 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3518 85 }
3519
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3520 {
3521 85 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3522 85 }
3523
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3524 {
3525 85 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3526 85 }
3527
3528
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if ( tempheader.zelda_version < 0x254 )
3529 {
3530 85 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3531 85 }
3532 //Sideview spikes in 2.50.0
3533
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 54 times.
115 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3534 {
3535 31 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3536 31 }
3537 //more 2.50 fixes -Z
3538
6/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 25 times.
115 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3539 {
3540 60 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3541 60 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3542 60 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3543 60 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3544 60 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3545
3546 60 }
3547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3548 {
3549 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3550 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3551 }
3552
3553
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(tempheader.zelda_version < 0x193)
3554 {
3555 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3556 4 }
3557
3558
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(tempheader.zelda_version < 0x255)
3559 {
3560 85 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3561 85 }
3562
3563
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3564 {
3565 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3566 9 }
3567
3568
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3569 {
3570 85 set_bit(quest_rules,qr_OLD_F6,1);
3571 85 }
3572
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3573 {
3574 85 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3575 85 }
3576
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3577 {
3578 85 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3579 85 }
3580
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3581 {
3582 85 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3583 85 }
3584 //}
3585
3586
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3587 85 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3588
3589
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 2) //Old CSet2 Handling
3590 85 set_bit(quest_rules,qr_OLDCS2,1);
3591
3592
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3593 85 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3594
3595
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3596 85 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3597
3598
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 76 times.
115 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3599 76 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3600
3601
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3602 85 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3603
3604
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3605 85 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3606
3607
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3608 85 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3609
3610
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 9)
3611 {
3612 //Hardcoded BS Patras
3613 85 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3614 //Hardcoded Patra Inner Eye offsets
3615 85 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3616 //Broken 'Big enemy' animation style
3617 85 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3618 //Broken Attribute 31/32
3619 85 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3620 85 }
3621
3622
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 10) //Shared candle use limits
3623 85 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3624
3625
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 11) //No cross-screen return points
3626 85 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3627
3628
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 12)
3629 {
3630 //Old fire trail duration
3631 85 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3632 //Old Intro String in Ganon Room Behavior
3633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3634 85 else set_bit(quest_rules,qr_GANONINTRO,1);
3635 85 }
3636
3637
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
115 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3638 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3639
3640
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 14) //Old Bridge Combo Behavior
3641 85 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3642
3643
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 15) //Broken Z3 Animation
3644 85 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3645
3646
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3647 85 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3648
3649
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 17)
3650 {
3651 //Old Quake/DrawYOffset behavior
3652 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3653 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3654 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3655 85 }
3656
3657
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 18)
3658 {
3659 //Broken DrawScreen Derivative Functions
3660 85 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3661 //Scrolling Cancels Charge
3662 85 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3663 85 }
3664
3665
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3666 85 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3667
3668
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 20)
3669 85 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3670
3671
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 21)
3672 {
3673 85 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3674 85 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3675 85 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3676 85 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3677 85 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3678 85 }
3679
3680
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 22)
3681 85 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3682
3683
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 23)
3684 85 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3685
3686
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 24)
3687 {
3688 85 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3689 85 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3690 85 }
3691
3692
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 25)
3693 {
3694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3695 85 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3696 85 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3697 85 }
3698
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 26)
3699 {
3700 85 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3701 85 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3702 85 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3703 85 }
3704
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3705 {
3706
2/2
✓ Branch 0 taken 25585 times.
✓ Branch 1 taken 85 times.
25670 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3707 25585 set_bit(quest_rules,q,0);
3708
2/2
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 85 times.
9605 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3709 9520 set_bit(quest_rules,q,0);
3710 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3711 85 }
3712
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 28)
3713 87 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3714
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 29)
3715 87 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3716
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 30)
3717 {
3718 87 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3719 87 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3720 87 }
3721
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 31)
3722 {
3723 87 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3724 87 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3725 87 }
3726
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 32)
3727 87 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3728
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 33)
3729 87 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3730
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(compatrule_version < 34)
3731 {
3732 87 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3733 87 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3734 87 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3735 87 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3736 87 }
3737
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 88 times.
115 if(compatrule_version < 35)
3738 {
3739 // Leaving this commented for now, might need to enable later -Em
3740 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3741 88 set_bit(quest_rules,qr_BROKEN_INPUT_DOWN_STATE,1);
3742 88 }
3743
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 88 times.
115 if(compatrule_version < 36)
3744 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3745
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 90 times.
115 if(compatrule_version < 37)
3746 90 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3747
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 90 times.
115 if(compatrule_version < 38)
3748 90 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3749
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 90 times.
115 if(compatrule_version < 39)
3750 90 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3751
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 90 times.
115 if(compatrule_version < 40)
3752 90 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3753
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 91 times.
115 if(compatrule_version < 41)
3754 91 set_bit(quest_rules,qr_BROKENHITBY,1);
3755
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 91 times.
115 if(compatrule_version < 42)
3756 91 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3757
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 91 times.
115 if(compatrule_version < 43)
3758 91 set_bit(quest_rules,qr_OLD_BOMB_HITBOXES,1);
3759
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 91 times.
115 if(compatrule_version < 44)
3760 91 set_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME,1);
3761
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 99 times.
115 if(compatrule_version < 45)
3762 99 set_bit(quest_rules,qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3763
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 99 times.
115 if(compatrule_version < 46)
3764 99 set_bit(quest_rules,qr_BROKEN_RAFT_SCROLL,1);
3765
3766 115 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3767
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if (s_version < 16)
3768 85 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3769
3770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
3771 115 memcpy(Header, &tempheader, sizeof(tempheader));
3772
3773 115 return 0;
3774 115 }
3775
3776 955235 void init_msgstr(MsgStr *str)
3777 {
3778 955235 str->s = "";
3779 955235 str->s.shrink_to_fit();
3780 955235 str->nextstring=0;
3781 955235 str->tile=0;
3782 955235 str->cset=0;
3783 955235 str->trans=false;
3784 955235 str->font=font_zfont;
3785 955235 str->y=32;
3786 955235 str->sfx=18;
3787 955235 str->listpos=0;
3788 955235 str->x=24;
3789 955235 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3790 955235 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3791 955235 str->hspace=0;
3792 955235 str->vspace=0;
3793 955235 str->stringflags=0;
3794 955235 str->margins[up] = 8;
3795 955235 str->margins[down] = 0;
3796 955235 str->margins[left] = 8;
3797 955235 str->margins[right] = 0;
3798 955235 str->portrait_tile = 0;
3799 955235 str->portrait_cset = 0;
3800 955235 str->portrait_x = 0;
3801 955235 str->portrait_y = 0;
3802 955235 str->portrait_tw = 1;
3803 955235 str->portrait_th = 1;
3804 955235 str->shadow_type = 0;
3805 955235 str->shadow_color = 0;
3806 955235 str->drawlayer = 6;
3807 955235 }
3808
3809 115 void init_msgstrings(int32_t start, int32_t end)
3810 {
3811
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(end <= start || end-start > msg_strings_size)
3812 return;
3813
3814
2/2
✓ Branch 0 taken 942080 times.
✓ Branch 1 taken 115 times.
942195 for(int32_t i=start; i<end; i++)
3815 {
3816 942080 init_msgstr(&MsgStrings[i]);
3817 942080 MsgStrings[i].listpos=i;
3818 942080 }
3819
3820
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(start==0)
3821 {
3822 115 MsgStrings[0].s = "(None)";
3823 115 MsgStrings[0].listpos = 0;
3824 115 }
3825 115 }
3826
3827 115 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3828 {
3829 115 MsgStr tempMsgString;
3830
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 init_msgstr(&tempMsgString);
3831
3832 115 word temp_msg_count=0;
3833 word temp_expansion[16];
3834 115 memset(temp_expansion, 0, 16*sizeof(word));
3835 115 char buf[8193] = {0};
3836
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version < 0x193)
3837 {
3838 byte tempbyte;
3839 4 int32_t strings_to_read=0;
3840
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3842 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3843 {
3844 4 strings_to_read=128;
3845 4 temp_msg_count=Header->old_str_count;
3846
3847 // Some sort of string count corruption seems to be common in old quests
3848
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3849 {
3850 temp_msg_count=128;
3851 }
3852 4 }
3853 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3854 {
3855 strings_to_read=255;
3856 temp_msg_count=Header->old_str_count;
3857 }
3858 else
3859 {
3860 if(!p_igetw(&temp_msg_count,f,true))
3861 {
3862 return qe_invalid;
3863 }
3864
3865 strings_to_read=temp_msg_count;
3866
3867 if(temp_msg_count >= msg_strings_size)
3868 {
3869 Z_message("Reallocating string buffer...\n");
3870
3871 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3872 // return qe_nomem;
3873
3874 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3875 delete[] MsgStrings;
3876 MsgStrings = new MsgStr[MAXMSGS];
3877 msg_strings_size = MAXMSGS;
3878 for(auto q = 0; q < msg_strings_size; ++q)
3879 {
3880 MsgStrings[q].clear();
3881 }
3882 }
3883 }
3884
3885 //reset the message strings
3886
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3887 {
3888
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3889 4 }
3890
3891
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3892 {
3893
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3894
3895
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3896 {
3897 return qe_invalid;
3898 }
3899
3900 512 buf[74] = '\0';
3901
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3902
3903
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3904 {
3905 return qe_invalid;
3906 }
3907
3908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3909 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3910 {
3911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3912
3913
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3914 {
3915 return qe_invalid;
3916 }
3917
3918
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3919 {
3920 return qe_invalid;
3921 }
3922 512 }
3923 else
3924 {
3925 if(!p_igetw(&tempMsgString.nextstring,f,true))
3926 {
3927 return qe_invalid;
3928 }
3929
3930 if(!pfread(temp_expansion,32,f,true))
3931 {
3932 return qe_invalid;
3933 }
3934 }
3935
3936
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3937 {
3938
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3939 512 }
3940 512 }
3941 4 }
3942 else
3943 {
3944 int32_t dummy_int;
3945 word s_version;
3946 word s_cversion;
3947
3948 //section version info
3949
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&s_version,f,true))
3950 {
3951 return qe_invalid;
3952 }
3953
3954 111 FFCore.quest_format[vStrings] = s_version;
3955
3956
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&s_cversion,f,true))
3957 {
3958 return qe_invalid;
3959 }
3960
3961 //al_trace("Strings version %d\n", s_version);
3962 //section size
3963
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetl(&dummy_int,f,true))
3964 {
3965 return qe_invalid;
3966 }
3967
3968 //finally... section data
3969
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&temp_msg_count,f,true))
3970 {
3971 return qe_invalid;
3972 }
3973
3974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(temp_msg_count >= msg_strings_size)
3975 {
3976 Z_message("Reallocating string buffer...\n");
3977
3978 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3979 // return qe_nomem;
3980 delete[] MsgStrings;
3981 MsgStrings = new MsgStr[MAXMSGS];
3982 msg_strings_size = MAXMSGS;
3983 for(auto q = 0; q < msg_strings_size; ++q)
3984 {
3985 MsgStrings[q].clear();
3986 }
3987 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3988 }
3989
3990 //reset the message strings
3991
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(keepdata)
3992 {
3993
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if(s_version < 7)
3994
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3995
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 init_msgstrings(0,msg_strings_size);
3996 111 }
3997
3998 111 int32_t string_length=(s_version<2)?73:145;
3999
4000
2/2
✓ Branch 0 taken 12528 times.
✓ Branch 1 taken 111 times.
12639 for(int32_t i=0; i<temp_msg_count; i++)
4001 {
4002
1/2
✓ Branch 0 taken 12528 times.
✗ Branch 1 not taken.
12528 init_msgstr(&tempMsgString);
4003
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 11648 times.
12528 if(s_version > 8)
4004 {
4005
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&string_length,f,true))
4006 {
4007 return qe_invalid;
4008 }
4009 880 }
4010
4011
2/4
✓ Branch 0 taken 12528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12528 times.
12528 if (string_length < 0 || string_length > 8193)
4012 {
4013 return qe_invalid;
4014 }
4015
4016
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 138 times.
12528 if (string_length > 0)
4017 {
4018
2/4
✓ Branch 0 taken 12390 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12390 times.
✗ Branch 3 not taken.
12390 if (!pfread(buf, string_length, f, true))
4019 {
4020 return qe_invalid;
4021 }
4022 12390 }
4023 else
4024 {
4025 138 buf[0] = 0;
4026 }
4027
4028
2/4
✓ Branch 0 taken 12528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12528 times.
✗ Branch 3 not taken.
12528 if(!p_igetw(&tempMsgString.nextstring,f,true))
4029 {
4030 return qe_invalid;
4031 }
4032
4033
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7882 times.
12528 if(s_version<2)
4034 {
4035 4646 buf[72] = '\0';
4036
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
4037 4646 }
4038 else
4039 {
4040 // June 2008: A bug corrupted the last 4 chars of a string.
4041 // Discard these.
4042
1/2
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
7882 if(s_version<3)
4043 {
4044 for(int32_t j=140; j<144; j++)
4045 {
4046 buf[j] = '\0';
4047 }
4048 }
4049
1/2
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
7882 if(string_length > 8192) string_length = 8192;
4050 7882 buf[string_length]='\0'; //Force-terminate
4051
1/2
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
7882 tempMsgString.s = buf;
4052
4053
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 7002 times.
7882 if ( s_version >= 6 )
4054 {
4055
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&tempMsgString.tile,f,true))
4056 {
4057 return qe_invalid;
4058 }
4059 880 }
4060 else
4061 {
4062
2/4
✓ Branch 0 taken 7002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
7002 if(!p_igetw(&tempMsgString.tile,f,true))
4063 {
4064 return qe_invalid;
4065 }
4066 }
4067
4068
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.cset,f,true))
4069 {
4070 return qe_invalid;
4071 }
4072
4073 byte dummy_char;
4074
4075
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4076 {
4077 return qe_invalid;
4078 }
4079
4080 7882 tempMsgString.trans=dummy_char!=0;
4081
4082
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.font,f,true))
4083 {
4084 return qe_invalid;
4085 }
4086
4087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7882 times.
7882 if(s_version < 5)
4088 {
4089 if(!p_getc(&tempMsgString.y,f,true))
4090 {
4091 return qe_invalid;
4092 }
4093 }
4094 else
4095 {
4096
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_igetw(&tempMsgString.x,f,true))
4097 {
4098 return qe_invalid;
4099 }
4100
4101
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_igetw(&tempMsgString.y,f,true))
4102 {
4103 return qe_invalid;
4104 }
4105
4106
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_igetw(&tempMsgString.w,f,true))
4107 {
4108 return qe_invalid;
4109 }
4110
4111
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_igetw(&tempMsgString.h,f,true))
4112 {
4113 return qe_invalid;
4114 }
4115
4116
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.hspace,f,true))
4117 {
4118 return qe_invalid;
4119 }
4120
4121
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.vspace,f,true))
4122 {
4123 return qe_invalid;
4124 }
4125
4126
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.stringflags,f,true))
4127 {
4128 return qe_invalid;
4129 }
4130 }
4131
4132
2/2
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 880 times.
7882 if(s_version >= 7)
4133 {
4134
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 3520 times.
4400 for(int32_t q = 0; q < 4; ++q)
4135 {
4136
2/4
✓ Branch 0 taken 3520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3520 times.
✗ Branch 3 not taken.
3520 if(!p_getc(&tempMsgString.margins[q],f,true))
4137 {
4138 return qe_invalid;
4139 }
4140 3520 }
4141
4142
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4143 {
4144 return qe_invalid;
4145 }
4146
4147
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4148 {
4149 return qe_invalid;
4150 }
4151
4152
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_x,f,true))
4153 {
4154 return qe_invalid;
4155 }
4156
4157
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_y,f,true))
4158 {
4159 return qe_invalid;
4160 }
4161
4162
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4163 {
4164 return qe_invalid;
4165 }
4166
4167
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.portrait_th,f,true))
4168 {
4169 return qe_invalid;
4170 }
4171 880 }
4172
4173
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 7002 times.
7882 if(s_version >= 8)
4174 {
4175
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.shadow_type,f,true))
4176 {
4177 return qe_invalid;
4178 }
4179
4180
2/4
✓ Branch 0 taken 880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 880 times.
✗ Branch 3 not taken.
880 if(!p_getc(&tempMsgString.shadow_color,f,true))
4181 {
4182 return qe_invalid;
4183 }
4184 880 }
4185
4186
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 7119 times.
7882 if(s_version >= 10)
4187 {
4188
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempMsgString.drawlayer,f,true))
4189 {
4190 return qe_invalid;
4191 }
4192 763 }
4193
4194
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_getc(&tempMsgString.sfx,f,true))
4195 {
4196 return qe_invalid;
4197 }
4198
4199
1/2
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
7882 if(s_version>3)
4200 {
4201
2/4
✓ Branch 0 taken 7882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7882 times.
✗ Branch 3 not taken.
7882 if(!p_igetw(&tempMsgString.listpos,f,true))
4202 {
4203 return qe_invalid;
4204 }
4205 7882 }
4206 }
4207
4208
1/2
✓ Branch 0 taken 12528 times.
✗ Branch 1 not taken.
12528 if(keepdata==true)
4209 {
4210
1/2
✓ Branch 0 taken 12528 times.
✗ Branch 1 not taken.
12528 MsgStrings[i].copyAll(tempMsgString);
4211 12528 }
4212 12528 }
4213 }
4214
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
4216 {
4217 115 msg_count=temp_msg_count;
4218 115 }
4219
4220 115 return 0;
4221 115 }
4222
4223 115 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4224 {
4225
2/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115 if((Header->zelda_version < 0x192)||
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4227 {
4228 4 return 0;
4229 }
4230
4231 111 word temp_door_combo_set_count=0;
4232 DoorComboSet tempDoorComboSet;
4233 word dummy_word;
4234 int32_t dummy_long;
4235 byte padding;
4236 111 int32_t s_version = 0;
4237
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(keepdata==true)
4239 {
4240
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 111 times.
28527 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4241 {
4242 28416 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4243 28416 }
4244 111 }
4245
4246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(Header->zelda_version > 0x192)
4247 {
4248 //section version info
4249
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
4250 {
4251 return qe_invalid;
4252 }
4253
4254 111 FFCore.quest_format[vDoors] = s_version;
4255
4256 //al_trace("Door combo sets version %d\n", dummy_word);
4257
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy_word,f,true))
4258 {
4259 return qe_invalid;
4260 }
4261
4262 //section size
4263
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy_long,f,true))
4264 {
4265 return qe_invalid;
4266 }
4267 111 }
4268
4269 //finally... section data
4270
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&temp_door_combo_set_count,f,true))
4271 {
4272 return qe_invalid;
4273 }
4274
4275
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4276 {
4277 return qe_invalid;
4278 }
4279
4280
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 111 times.
964 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4281 {
4282 853 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4283
4284 //name
4285
1/2
✓ Branch 0 taken 853 times.
✗ Branch 1 not taken.
853 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4286 {
4287 return qe_invalid;
4288 }
4289
4290
1/2
✓ Branch 0 taken 853 times.
✗ Branch 1 not taken.
853 if(Header->zelda_version < 0x193)
4291 {
4292 if(!p_getc(&padding,f,true))
4293 {
4294 return qe_invalid;
4295 }
4296 }
4297
4298 //up door
4299
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4300 {
4301
2/2
✓ Branch 0 taken 30708 times.
✓ Branch 1 taken 7677 times.
38385 for(int32_t k=0; k<4; k++)
4302 {
4303
1/2
✓ Branch 0 taken 30708 times.
✗ Branch 1 not taken.
30708 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4304 {
4305 return qe_invalid;
4306 }
4307 30708 }
4308 7677 }
4309
4310
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4311 {
4312
2/2
✓ Branch 0 taken 30708 times.
✓ Branch 1 taken 7677 times.
38385 for(int32_t k=0; k<4; k++)
4313 {
4314
1/2
✓ Branch 0 taken 30708 times.
✗ Branch 1 not taken.
30708 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4315 {
4316 return qe_invalid;
4317 }
4318 30708 }
4319 7677 }
4320
4321 //down door
4322
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4323 {
4324
2/2
✓ Branch 0 taken 30708 times.
✓ Branch 1 taken 7677 times.
38385 for(int32_t k=0; k<4; k++)
4325 {
4326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30708 times.
30708 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4327 {
4328 return qe_invalid;
4329 }
4330 30708 }
4331 7677 }
4332
4333
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4334 {
4335
2/2
✓ Branch 0 taken 30708 times.
✓ Branch 1 taken 7677 times.
38385 for(int32_t k=0; k<4; k++)
4336 {
4337
1/2
✓ Branch 0 taken 30708 times.
✗ Branch 1 not taken.
30708 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4338 {
4339 return qe_invalid;
4340 }
4341 30708 }
4342 7677 }
4343
4344 //left door
4345
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4346 {
4347
2/2
✓ Branch 0 taken 46062 times.
✓ Branch 1 taken 7677 times.
53739 for(int32_t k=0; k<6; k++)
4348 {
4349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46062 times.
46062 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4350 {
4351 return qe_invalid;
4352 }
4353 46062 }
4354 7677 }
4355
4356
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4357 {
4358
2/2
✓ Branch 0 taken 46062 times.
✓ Branch 1 taken 7677 times.
53739 for(int32_t k=0; k<6; k++)
4359 {
4360
1/2
✓ Branch 0 taken 46062 times.
✗ Branch 1 not taken.
46062 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4361 {
4362 return qe_invalid;
4363 }
4364 46062 }
4365 7677 }
4366
4367 //right door
4368
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4369 {
4370
2/2
✓ Branch 0 taken 46062 times.
✓ Branch 1 taken 7677 times.
53739 for(int32_t k=0; k<6; k++)
4371 {
4372
1/2
✓ Branch 0 taken 46062 times.
✗ Branch 1 not taken.
46062 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4373 {
4374 return qe_invalid;
4375 }
4376 46062 }
4377 7677 }
4378
4379
2/2
✓ Branch 0 taken 7677 times.
✓ Branch 1 taken 853 times.
8530 for(int32_t j=0; j<9; j++)
4380 {
4381
2/2
✓ Branch 0 taken 46062 times.
✓ Branch 1 taken 7677 times.
53739 for(int32_t k=0; k<6; k++)
4382 {
4383
1/2
✓ Branch 0 taken 46062 times.
✗ Branch 1 not taken.
46062 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4384 {
4385 return qe_invalid;
4386 }
4387 46062 }
4388 7677 }
4389
4390 //up bomb rubble
4391
2/2
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 853 times.
2559 for(int32_t j=0; j<2; j++)
4392 {
4393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1706 times.
1706 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4394 {
4395 return qe_invalid;
4396 }
4397 1706 }
4398
4399
2/2
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 853 times.
2559 for(int32_t j=0; j<2; j++)
4400 {
4401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1706 times.
1706 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4402 {
4403 return qe_invalid;
4404 }
4405 1706 }
4406
4407 //down bomb rubble
4408
2/2
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 853 times.
2559 for(int32_t j=0; j<2; j++)
4409 {
4410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1706 times.
1706 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4411 {
4412 return qe_invalid;
4413 }
4414 1706 }
4415
4416
2/2
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 853 times.
2559 for(int32_t j=0; j<2; j++)
4417 {
4418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1706 times.
1706 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4419 {
4420 return qe_invalid;
4421 }
4422 1706 }
4423
4424 //left bomb rubble
4425
2/2
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 853 times.
3412 for(int32_t j=0; j<3; j++)
4426 {
4427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2559 times.
2559 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4428 {
4429 return qe_invalid;
4430 }
4431 2559 }
4432
4433
2/2
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 853 times.
3412 for(int32_t j=0; j<3; j++)
4434 {
4435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2559 times.
2559 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4436 {
4437 return qe_invalid;
4438 }
4439 2559 }
4440
4441
1/2
✓ Branch 0 taken 853 times.
✗ Branch 1 not taken.
853 if(Header->zelda_version < 0x193)
4442 {
4443 if(!p_getc(&padding,f,true))
4444 {
4445 return qe_invalid;
4446 }
4447
4448 }
4449
4450 //right bomb rubble
4451
2/2
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 853 times.
3412 for(int32_t j=0; j<3; j++)
4452 {
4453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2559 times.
2559 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4454 {
4455 return qe_invalid;
4456 }
4457 2559 }
4458
4459
2/2
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 853 times.
3412 for(int32_t j=0; j<3; j++)
4460 {
4461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2559 times.
2559 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4462 {
4463 return qe_invalid;
4464 }
4465 2559 }
4466
4467
1/2
✓ Branch 0 taken 853 times.
✗ Branch 1 not taken.
853 if(Header->zelda_version < 0x193)
4468 {
4469 if(!p_getc(&padding,f,true))
4470 {
4471 return qe_invalid;
4472 }
4473 }
4474
4475 //walkthrough stuff
4476
2/2
✓ Branch 0 taken 3412 times.
✓ Branch 1 taken 853 times.
4265 for(int32_t j=0; j<4; j++)
4477 {
4478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
3412 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4479 {
4480 return qe_invalid;
4481 }
4482 3412 }
4483
4484
2/2
✓ Branch 0 taken 3412 times.
✓ Branch 1 taken 853 times.
4265 for(int32_t j=0; j<4; j++)
4485 {
4486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
3412 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4487 {
4488 return qe_invalid;
4489 }
4490 3412 }
4491
4492 //flags
4493
2/2
✓ Branch 0 taken 1706 times.
✓ Branch 1 taken 853 times.
2559 for(int32_t j=0; j<2; j++)
4494 {
4495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1706 times.
1706 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4496 {
4497 return qe_invalid;
4498 }
4499 1706 }
4500
4501
1/2
✓ Branch 0 taken 853 times.
✗ Branch 1 not taken.
853 if(Header->zelda_version < 0x193)
4502 {
4503 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4504 {
4505 return qe_invalid;
4506 }
4507 }
4508
4509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 853 times.
853 if(keepdata==true)
4510 {
4511 853 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4512 853 }
4513 853 }
4514
4515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(keepdata==true)
4516 {
4517 111 door_combo_set_count=temp_door_combo_set_count;
4518 111 }
4519
4520 111 return 0;
4521 115 }
4522
4523 int32_t count_dmaps()
4524 {
4525 int32_t i=MAXDMAPS-1;
4526 bool found=false;
4527
4528 while(i>=0 && !found)
4529 {
4530 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4531 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4532 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4533 found=true;
4534
4535 for(int32_t j=0; j<8; j++)
4536 {
4537 if(DMaps[i].grid[j]!=0)
4538
4539 found=true;
4540 }
4541
4542 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4543 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4544 found=true;
4545
4546 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4547 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4548 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4549 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4550 found=true;
4551
4552 if(!found)
4553 {
4554 i--;
4555 }
4556 }
4557
4558 return i+1;
4559 }
4560
4561
4562 int32_t count_shops(miscQdata *Misc)
4563 {
4564 int32_t i=NUM_SHOPS-1,j;
4565 bool found=false;
4566
4567 while(i>=0 && !found)
4568 {
4569 j=2;
4570
4571 while(j>=0 && !found)
4572 {
4573 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4574 {
4575 found=true;
4576 }
4577 else
4578 {
4579 j--;
4580 }
4581 }
4582
4583 if(Misc->shop[i].name[0]!=0)
4584 {
4585 found=true;
4586 }
4587
4588 if(!found)
4589 {
4590 i--;
4591 }
4592 }
4593
4594 return i+1;
4595 }
4596
4597 int32_t count_infos(miscQdata *Misc)
4598 {
4599 int32_t i=255,j;
4600 bool found=false;
4601
4602 while(i>=0 && !found)
4603 {
4604 j=2;
4605
4606 while(j>=0 && !found)
4607 {
4608 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4609 {
4610 found=true;
4611 }
4612 else
4613 {
4614 j--;
4615 }
4616 }
4617
4618 if(Misc->info[i].name[0]!=0)
4619 {
4620 found=true;
4621 }
4622
4623 if(!found)
4624 {
4625 i--;
4626 }
4627 }
4628
4629 return i+1;
4630 }
4631
4632 int32_t count_warprings(miscQdata *Misc)
4633 {
4634 int32_t i=15,j;
4635 bool found=false;
4636
4637 while(i>=0 && !found)
4638 {
4639 j=7;
4640
4641 while(j>=0 && !found)
4642 {
4643 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4644 {
4645 found=true;
4646 }
4647 else
4648 {
4649 j--;
4650 }
4651 }
4652
4653 if(!found)
4654 {
4655 i--;
4656 }
4657 }
4658
4659 return i+1;
4660 }
4661
4662 int32_t count_palcycles(miscQdata *Misc)
4663 {
4664 int32_t i=255,j;
4665 bool found=false;
4666
4667 while(i>=0 && !found)
4668 {
4669 j=2;
4670
4671 while(j>=0 && !found)
4672 {
4673 if(Misc->cycles[i][j].count!=0)
4674 {
4675 found=true;
4676 }
4677 else
4678 {
4679 j--;
4680 }
4681 }
4682
4683 if(!found)
4684 {
4685 i--;
4686 }
4687 }
4688
4689 return i+1;
4690 }
4691
4692 203635 void clear_screen(mapscr *temp_scr)
4693 {
4694 203635 temp_scr->zero_memory();
4695 203635 }
4696
4697 115 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4698 {
4699 115 word dmapstoread=0;
4700 dmap tempDMap;
4701
4702 int32_t dummy;
4703 115 word s_version=0, s_cversion=0;
4704 byte padding;
4705
4706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
4707 {
4708
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<max_dmaps; i++)
4709 {
4710 58880 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4711 58880 sprintf(DMaps[start_dmap+i].title," ");
4712 58880 sprintf(DMaps[start_dmap+i].intro," ");
4713 58880 DMaps[start_dmap+i].type |= dmCAVE;
4714 58880 }
4715 115 }
4716
4717
3/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 4 times.
115 if(!Header || Header->zelda_version > 0x192)
4718 {
4719 //section version info
4720
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
4721 {
4722 return qe_invalid;
4723 }
4724
4725 111 FFCore.quest_format[vDMaps] = s_version;
4726
4727 //al_trace("DMaps version %d\n", s_version);
4728
4729
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_cversion,f,true))
4730 {
4731 return qe_invalid;
4732 }
4733
4734 //section size
4735
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
4736 {
4737 return qe_invalid;
4738 }
4739
4740 //finally... section data
4741
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dmapstoread,f,true))
4742 {
4743 return qe_invalid;
4744 }
4745 111 }
4746 else
4747 {
4748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4749 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4750 {
4751 4 dmapstoread=32;
4752 4 }
4753 else if(s_version <= 4)
4754 {
4755 dmapstoread=OLDMAXDMAPS;
4756 }
4757 else
4758 {
4759 dmapstoread=MAXDMAPS;
4760 }
4761 }
4762
4763
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 dmapstoread=zc_min(dmapstoread, max_dmaps);
4764
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4765
4766
2/2
✓ Branch 0 taken 55680 times.
✓ Branch 1 taken 115 times.
55795 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4767 {
4768 55680 memset(&tempDMap,0,sizeof(dmap));
4769 55680 sprintf(tempDMap.title," ");
4770 55680 sprintf(tempDMap.intro," ");
4771
4772
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.map,f,keepdata))
4773 {
4774 return qe_invalid;
4775 }
4776
4777
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 54272 times.
55680 if(s_version <= 4)
4778 {
4779 byte tempbyte;
4780
4781
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4782 {
4783 return qe_invalid;
4784 }
4785
4786 1408 tempDMap.level=(word)tempbyte;
4787 1408 }
4788 else
4789 {
4790
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&tempDMap.level,f,keepdata))
4791 {
4792 return qe_invalid;
4793 }
4794 }
4795
4796
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.xoff,f,keepdata))
4797 {
4798 return qe_invalid;
4799 }
4800
4801
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.compass,f,keepdata))
4802 {
4803 return qe_invalid;
4804 }
4805
4806
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 1408 times.
55680 if(s_version > 8) // February 2009
4807 {
4808
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&tempDMap.color,f,true))
4809 {
4810 return qe_invalid;
4811 }
4812 54272 }
4813 else
4814 {
4815 byte tempbyte;
4816
4817
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4818 {
4819 return qe_invalid;
4820 }
4821
4822 1408 tempDMap.color = (word)tempbyte;
4823 }
4824
4825
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.midi,f,keepdata))
4826 {
4827 return qe_invalid;
4828 }
4829
4830
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.cont,f,keepdata))
4831 {
4832 return qe_invalid;
4833 }
4834
4835
1/2
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
55680 if(!p_getc(&tempDMap.type,f,keepdata))
4836 {
4837 return qe_invalid;
4838 }
4839
4840
4/4
✓ Branch 0 taken 705 times.
✓ Branch 1 taken 54975 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 12 times.
56385 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4841
1/2
✓ Branch 0 taken 705 times.
✗ Branch 1 not taken.
705 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4842 693 tempDMap.xoff = 0;
4843
4844
2/2
✓ Branch 0 taken 445440 times.
✓ Branch 1 taken 55680 times.
501120 for(int32_t j=0; j<8; j++)
4845 {
4846
1/2
✓ Branch 0 taken 445440 times.
✗ Branch 1 not taken.
445440 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4847 {
4848 return qe_invalid;
4849 }
4850 445440 }
4851
4852
4/8
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55552 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55680 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4853 {
4854
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4855 {
4856 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4857 38 }
4858
4859
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4860 {
4861 4 tempDMap.cont-=tempDMap.xoff;
4862 4 tempDMap.compass-=tempDMap.xoff;
4863 4 }
4864
4865 //forgotten -DD
4866
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4867 {
4868 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4869 90 }
4870 128 }
4871 else
4872 {
4873
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4874 {
4875 return qe_invalid;
4876 }
4877
4878
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4879 {
4880 return qe_invalid;
4881 }
4882
4883
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4884 {
4885 return qe_invalid;
4886 }
4887
4888
3/8
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 55552 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55552 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4889 {
4890 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4891 if(keepdata==true)
4892 {
4893 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4894 }
4895
4896 continue;
4897 }
4898
4899
2/4
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
55552 if(Header && (Header->zelda_version < 0x193))
4900 {
4901 if(!p_getc(&padding,f,keepdata))
4902 {
4903 return qe_invalid;
4904 }
4905 }
4906
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40192 times.
55552 if ( s_version >= 11 )
4907 {
4908
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4909 {
4910 return qe_invalid;
4911 }
4912 15360 }
4913 else
4914 {
4915
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4916 {
4917 return qe_invalid;
4918 }
4919 }
4920
4921
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4922 {
4923 return qe_invalid;
4924 }
4925
4926
2/4
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
55552 if(Header && (Header->zelda_version < 0x193))
4927 {
4928 if(!p_getc(&padding,f,keepdata))
4929 {
4930 return qe_invalid;
4931 }
4932 }
4933
4934
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40192 times.
55552 if ( s_version >= 11 )
4935 {
4936
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4937 {
4938 return qe_invalid;
4939 }
4940 15360 }
4941 else
4942 {
4943
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4944 {
4945 return qe_invalid;
4946 }
4947 }
4948
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4949 {
4950 return qe_invalid;
4951 }
4952
4953
2/4
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
55552 if(Header && (Header->zelda_version < 0x193))
4954 {
4955 if(!p_getc(&padding,f,keepdata))
4956 {
4957 return qe_invalid;
4958 }
4959 }
4960
4961
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40192 times.
55552 if ( s_version >= 11 )
4962 {
4963
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4964 {
4965 return qe_invalid;
4966 }
4967 15360 }
4968 else
4969 {
4970
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4971 {
4972 return qe_invalid;
4973 }
4974 }
4975
4976
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4977 {
4978 return qe_invalid;
4979 }
4980
4981
2/4
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55552 times.
✗ Branch 3 not taken.
55552 if(Header && (Header->zelda_version < 0x193))
4982 {
4983
4984 if(!p_getc(&padding,f,keepdata))
4985 {
4986 return qe_invalid;
4987 }
4988 }
4989
4990
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40192 times.
55552 if ( s_version >= 11 )
4991 {
4992
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4993 {
4994 return qe_invalid;
4995 }
4996 15360 }
4997 else
4998 {
4999
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
5000 {
5001 return qe_invalid;
5002 }
5003 }
5004
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
5005 {
5006 return qe_invalid;
5007 }
5008
5009
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
5010 {
5011 return qe_invalid;
5012 }
5013 }
5014
5015
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 54272 times.
55680 if(s_version>1)
5016 {
5017
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
5018 {
5019 return qe_invalid;
5020 }
5021
5022
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
5023 {
5024 return qe_invalid;
5025 }
5026
5027
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
5028 {
5029 return qe_invalid;
5030 }
5031 54272 }
5032
5033
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 54272 times.
55680 if(s_version>2)
5034 {
5035 byte di[32];
5036
5037
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!pfread(&di, 32, f, true)) return qe_invalid;
5038
5039
2/2
✓ Branch 0 taken 13893632 times.
✓ Branch 1 taken 54272 times.
13947904 for(int32_t j=0; j<MAXITEMS; j++)
5040 {
5041
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13893625 times.
13893632 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5042 13893625 else tempDMap.disableditems[j]=0;
5043 13893632 }
5044 54272 }
5045
5046
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 1408 times.
55680 if(s_version >= 6)
5047 {
5048
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&tempDMap.flags,f,keepdata))
5049 {
5050 return qe_invalid;
5051 }
5052 54272 }
5053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
5054 {
5055 char temp;
5056
5057 if(!p_getc(&temp,f,keepdata))
5058 {
5059 return qe_invalid;
5060 }
5061
5062 tempDMap.flags = temp;
5063 }
5064
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5065 {
5066 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5067 697 }
5068 else
5069 711 tempDMap.flags=0;
5070
5071
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 1408 times.
55680 if(s_version<7)
5072 {
5073
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5074 697 tempDMap.flags|= dmfVIEWMAP;
5075 1408 }
5076
5077
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 1408 times.
55680 if(s_version<8)
5078 {
5079
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5080 {
5081 609 tempDMap.type &= ~dmDNGN;
5082 609 tempDMap.type |= dmCAVE;
5083 609 }
5084
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5085 {
5086 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5087 469 }
5088 1408 }
5089
5090
5/8
✓ Branch 0 taken 55680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 55552 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 55552 times.
✗ Branch 7 not taken.
55680 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5091 55552 && (Header->zelda_version < 0x193))
5092 {
5093 if(!p_getc(&padding,f,keepdata))
5094 {
5095 return qe_invalid;
5096 }
5097 }
5098
5099
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 15360 times.
55680 if(s_version >= 10)
5100 {
5101
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempDMap.sideview,f,keepdata))
5102 {
5103 return qe_invalid;
5104 }
5105 15360 }
5106
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if(s_version < 10) tempDMap.sideview = 0;
5107
5108 //Dmap Scripts
5109
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 15360 times.
55680 if(s_version >= 12)
5110 {
5111
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.script,f,keepdata))
5112 {
5113 return qe_invalid;
5114 }
5115
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
5116 {
5117
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5118 {
5119 return qe_invalid;
5120 }
5121 122880 }
5122 15360 }
5123
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if ( s_version < 12 )
5124 {
5125 40320 tempDMap.script = 0;
5126
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5127 {
5128 322560 tempDMap.initD[q] = 0;
5129 322560 }
5130 40320 }
5131
5132
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 15360 times.
55680 if(s_version >= 13)
5133 {
5134
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
5135 {
5136
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
5137 {
5138
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5139 {
5140 return qe_invalid;
5141 }
5142 7987200 }
5143 122880 }
5144 15360 }
5145
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if ( s_version < 13 )
5146 {
5147 40320 tempDMap.script = 0;
5148
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5149 {
5150
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for ( int32_t w = 0; w < 65; w++ )
5151 20966400 tempDMap.initD_label[q][w] = 0;
5152 322560 }
5153 40320 }
5154
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if(s_version >= 14)
5155 {
5156
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5157 {
5158 return qe_invalid;
5159 }
5160
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5161 {
5162 return qe_invalid;
5163 }
5164
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; ++q )
5165 {
5166
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5167 {
5168 return qe_invalid;
5169 }
5170 122880 }
5171
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for(int32_t q = 0; q < 8; ++q)
5172 {
5173
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; ++w )
5174 {
5175
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5176 {
5177 return qe_invalid;
5178 }
5179 7987200 }
5180 122880 }
5181 15360 }
5182 else
5183 {
5184 40320 tempDMap.active_sub_script = 0;
5185 40320 tempDMap.passive_sub_script = 0;
5186
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5187 {
5188 322560 tempDMap.sub_initD[q] = 0;
5189
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5190 20966400 tempDMap.sub_initD_label[q][w] = 0;
5191 322560 }
5192 }
5193
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if(s_version >= 15)
5194 {
5195
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5196 {
5197 return qe_invalid;
5198 }
5199
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; ++q )
5200 {
5201
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5202 {
5203 return qe_invalid;
5204 }
5205 122880 }
5206
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for(int32_t q = 0; q < 8; ++q)
5207 {
5208
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; ++w )
5209 {
5210
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5211 {
5212 return qe_invalid;
5213 }
5214 7987200 }
5215 122880 }
5216 15360 }
5217 else
5218 {
5219 40320 tempDMap.onmap_script = 0;
5220
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5221 {
5222 322560 tempDMap.onmap_initD[q] = 0;
5223
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5224 {
5225 20966400 tempDMap.onmap_initD_label[q][w] = 0;
5226 20966400 }
5227 322560 }
5228 }
5229
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 40320 times.
55680 if(s_version >= 16)
5230 {
5231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5232 {
5233 return qe_invalid;
5234 }
5235 15360 }
5236 else
5237 {
5238 40320 tempDMap.mirrorDMap = -1;
5239 }
5240
5241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55680 times.
55680 if(keepdata==true)
5242 {
5243 55680 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5244 55680 }
5245 55680 }
5246
5247 115 return 0;
5248 115 }
5249
5250 106 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5251 {
5252 //these are here to bypass compiler warnings about unused arguments
5253 106 Header=Header;
5254
5255 miscQdata temp_misc;
5256 106 word s_version=0, s_cversion=0;
5257 106 int32_t tempsize=0;
5258 word dummyw;
5259
5260 106 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5261
5262 //section version info
5263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
5264 {
5265 return qe_invalid;
5266 }
5267
5268 106 FFCore.quest_format[vColours] = s_version;
5269
5270 106 al_trace("Misc Colours section version: %d\n", s_version);
5271
5272 //al_trace("Misc. colors version %d\n", s_version);
5273
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
5274 {
5275 return qe_invalid;
5276 }
5277
5278
5279 //section size
5280
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&tempsize,f,true))
5281 {
5282 return qe_invalid;
5283 }
5284
5285 //finally... section data
5286 106 readsize=0;
5287
5288
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.text,f,true))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.caption,f,true))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5309 {
5310 return qe_invalid;
5311 }
5312
5313
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5319 {
5320 return qe_invalid;
5321 }
5322
5323
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5349 {
5350 return qe_invalid;
5351 }
5352
5353
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5354 {
5355 return qe_invalid;
5356 }
5357
5358
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5359 {
5360 return qe_invalid;
5361 }
5362
5363
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5364 {
5365 return qe_invalid;
5366 }
5367
5368
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5369 {
5370 return qe_invalid;
5371 }
5372
5373
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5374 {
5375 return qe_invalid;
5376 }
5377
5378
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5379 {
5380 return qe_invalid;
5381 }
5382
5383
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5384 {
5385 return qe_invalid;
5386 }
5387
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if(s_version < 4)
5388 {
5389
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5390 return qe_invalid;
5391 76 temp_misc.colors.triforce_tile = dummyw;
5392
5393
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5394 return qe_invalid;
5395 76 temp_misc.colors.triframe_tile = dummyw;
5396
5397
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5398 return qe_invalid;
5399 76 temp_misc.colors.overworld_map_tile = dummyw;
5400
5401
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5402 return qe_invalid;
5403 76 temp_misc.colors.dungeon_map_tile = dummyw;
5404
5405
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5406 return qe_invalid;
5407 76 temp_misc.colors.blueframe_tile = dummyw;
5408
5409
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5410 return qe_invalid;
5411 76 temp_misc.colors.HCpieces_tile = dummyw;
5412 76 }
5413
5414
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5415 {
5416 return qe_invalid;
5417 }
5418
5419
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5420 {
5421 return qe_invalid;
5422 }
5423
5424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version < 2)
5425 {
5426 temp_misc.colors.msgtext = 0x01;
5427 }
5428 else
5429 {
5430
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5431 {
5432 return qe_invalid;
5433 }
5434 }
5435
5436
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if ( s_version >= 3 ) //expanded tile pages to 825
5437 {
5438
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5439 {
5440 return qe_invalid;
5441 }
5442
5443
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5444 {
5445 return qe_invalid;
5446 }
5447
5448
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5449 {
5450 return qe_invalid;
5451 }
5452
5453
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5454 {
5455 return qe_invalid;
5456 }
5457
5458
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5459 {
5460 return qe_invalid;
5461 }
5462
5463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5464 {
5465 return qe_invalid;
5466 }
5467 30 }
5468
5469
5470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata==true)
5471 {
5472 106 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5473 106 }
5474
5475 106 return 0;
5476 106 }
5477
5478 106 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5479 {
5480 miscQdata temp_misc;
5481 106 word s_version=0, s_cversion=0;
5482 byte icons;
5483 106 int32_t tempsize=0;
5484
5485 106 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5486
5487 //section version info
5488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
5489 {
5490 return qe_invalid;
5491 }
5492
5493 106 FFCore.quest_format[vIcons] = s_version;
5494
5495 //al_trace("Game icons version %d\n", s_version);
5496
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
5497 {
5498 return qe_invalid;
5499 }
5500
5501
5502 //section size
5503
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&tempsize,f,true))
5504 {
5505 return qe_invalid;
5506 }
5507
5508 //finally... section data
5509 106 readsize=0;
5510
5511 106 icons=4;
5512
5513
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if ( s_version >= 10 )
5514 {
5515
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<icons; i++)
5516 {
5517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&temp_misc.icons[i],f,true))
5518 {
5519 return qe_invalid;
5520 }
5521 120 }
5522 30 }
5523 else
5524 {
5525
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<icons; i++)
5526 {
5527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_igetw(&temp_misc.icons[i],f,true))
5528 {
5529 return qe_invalid;
5530 }
5531 304 }
5532 }
5533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata==true)
5534 {
5535 106 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5536 106 }
5537
5538 106 return 0;
5539 106 }
5540
5541 115 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5542 {
5543 115 word maxinfos=256;
5544 115 word maxshops=256;
5545 115 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5546 115 word ponds=16, pondsize=72, expansionsize=98*2;
5547 byte tempbyte, padding;
5548 miscQdata temp_misc;
5549 115 word s_version=0, s_cversion=0;
5550 word swaptmp;
5551 115 int32_t tempsize=0;
5552
5553 115 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5554
5555
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<maxshops; ++i)
5556 {
5557 29440 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5558 29440 }
5559
5560
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<maxinfos; ++i)
5561 {
5562 29440 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5563 29440 }
5564
5565
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
5566 {
5567 //section version info
5568
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
5569 {
5570 return qe_invalid;
5571 }
5572
5573 111 FFCore.quest_format[vMisc] = s_version;
5574
5575 //al_trace("Misc. data version %d\n", s_version);
5576
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_cversion,f,true))
5577 {
5578 return qe_invalid;
5579 }
5580
5581
5582 //section size
5583
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&tempsize,f,true))
5584 {
5585 return qe_invalid;
5586 }
5587 111 }
5588
5589 //finally... section data
5590 115 readsize=0;
5591
5592 //shops
5593
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
5594 {
5595
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&shops,f,true))
5596 {
5597 return qe_invalid;
5598 }
5599 111 }
5600
5601
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if (!(shops >= 0 && shops <= NUM_SHOPS))
5602 {
5603 return qe_invalid;
5604 }
5605
5606
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 115 times.
1354 for(int32_t i=0; i<shops; i++)
5607 {
5608
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1121 times.
1239 if(s_version > 6)
5609 {
5610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1121 times.
1121 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5611 {
5612 return qe_invalid;
5613 }
5614 1121 }
5615
5616
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 1239 times.
4956 for(int32_t j=0; j<3; j++)
5617 {
5618
1/2
✓ Branch 0 taken 3717 times.
✗ Branch 1 not taken.
3717 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5619 {
5620 return qe_invalid;
5621 }
5622
5623
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 354 times.
3717 if(s_version < 4)
5624 {
5625 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5626 354 }
5627 3717 }
5628
5629
2/2
✓ Branch 0 taken 1175 times.
✓ Branch 1 taken 64 times.
1239 if(Header->zelda_version < 0x193)
5630 {
5631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5632 {
5633 return qe_invalid;
5634 }
5635 64 }
5636
5637
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 1239 times.
4956 for(int32_t j=0; j<3; j++)
5638 {
5639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3717 times.
3717 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5640 {
5641 return qe_invalid;
5642 }
5643 3717 }
5644
5645
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1121 times.
1239 if(s_version > 3)
5646 {
5647
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 1121 times.
4484 for(int32_t j=0; j<3; j++)
5648 {
5649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3363 times.
3363 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5650 return qe_invalid;
5651 3363 }
5652 1121 }
5653
5654 /*
5655 if(s_version < 8)
5656 {
5657 for(int32_t j=0; j<3; j++)
5658 {
5659 (&temp_misc.shop[i].str[j])=0; //initialise.
5660 }
5661 }
5662 */
5663 1239 }
5664
5665 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5666
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<maxshops; ++i)
5667 {
5668
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 29440 times.
88320 for(int32_t j=0; j<3-1; j++)
5669 {
5670
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 85786 times.
144666 for(int32_t k=0; k<2-j; k++)
5671 {
5672 85786 if(temp_misc.shop[i].hasitem[k]==0)
5673 {
5674 85786 swaptmp = temp_misc.shop[i].item[k];
5675 85786 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5676 85786 temp_misc.shop[i].item[k+1] = swaptmp;
5677 85786 swaptmp = temp_misc.shop[i].price[k];
5678 85786 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5679 85786 temp_misc.shop[i].price[k+1] = swaptmp;
5680 85786 swaptmp = temp_misc.shop[i].hasitem[k];
5681 85786 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5682 85786 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5683 85786 }
5684 85786 }
5685 58880 }
5686 29440 }
5687
5688 //infos
5689
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
5690 {
5691
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&infos,f,true))
5692 {
5693 return qe_invalid;
5694 }
5695 111 }
5696
5697
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if (!(infos >= 0 && infos <= NUM_INFOS))
5698 {
5699 return qe_invalid;
5700 }
5701
5702
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 115 times.
1749 for(int32_t i=0; i<infos; i++)
5703 {
5704
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1555 times.
1634 if(s_version > 6)
5705 {
5706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1555 times.
1555 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5707 {
5708 return qe_invalid;
5709 }
5710 1555 }
5711
5712
2/2
✓ Branch 0 taken 4902 times.
✓ Branch 1 taken 1634 times.
6536 for(int32_t j=0; j<3; j++)
5713 {
5714
2/4
✓ Branch 0 taken 4710 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4902 if((Header->zelda_version < 0x192)||
5715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4710 times.
4710 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5716 {
5717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5718 {
5719 return qe_invalid;
5720 }
5721
5722 192 temp_misc.info[i].str[j]=tempbyte;
5723 192 }
5724 else
5725 {
5726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4710 times.
4710 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5727 {
5728 return qe_invalid;
5729 }
5730 }
5731 4902 }
5732
5733
2/2
✓ Branch 0 taken 1570 times.
✓ Branch 1 taken 64 times.
1634 if(Header->zelda_version < 0x193)
5734 {
5735
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5736 {
5737 return qe_invalid;
5738 }
5739 64 }
5740
5741
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1634 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1634 if((Header->zelda_version == 0x192)&&(Header->build>145))
5742 {
5743 if(!p_getc(&padding,f,true))
5744 {
5745 return qe_invalid;
5746 }
5747 }
5748
5749
2/2
✓ Branch 0 taken 4902 times.
✓ Branch 1 taken 1634 times.
6536 for(int32_t j=0; j<3; j++)
5750 {
5751
1/2
✓ Branch 0 taken 4902 times.
✗ Branch 1 not taken.
4902 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5752 {
5753 return qe_invalid;
5754 }
5755 4902 }
5756 1634 }
5757
5758 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5759
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<maxinfos; ++i)
5760 {
5761
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 29440 times.
88320 for(int32_t j=0; j<3-1; j++)
5762 {
5763
2/2
✓ Branch 0 taken 88320 times.
✓ Branch 1 taken 58880 times.
147200 for(int32_t k=0; k<2-j; k++)
5764 {
5765
2/2
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 86415 times.
88320 if(temp_misc.info[i].str[k]==0)
5766 {
5767 86415 swaptmp = temp_misc.info[i].str[k];
5768 86415 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5769 86415 temp_misc.info[i].str[k+1] = swaptmp;
5770 86415 swaptmp = temp_misc.info[i].price[k];
5771 86415 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5772 86415 temp_misc.info[i].price[k+1] = swaptmp;
5773 86415 }
5774 88320 }
5775 58880 }
5776 29440 }
5777
5778
5779 //warp rings
5780
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 if(s_version > 5)
5781 106 warprings++;
5782
5783
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
5784 {
5785
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&warprings,f,true))
5786 {
5787 return qe_invalid;
5788 }
5789
5790
3/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 30 times.
111 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5791 {
5792 // return qe_invalid;
5793 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5794 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5795 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5796 30 }
5797 111 }
5798
5799
2/2
✓ Branch 0 taken 1121 times.
✓ Branch 1 taken 115 times.
1236 for(int32_t i=0; i<warprings; i++)
5800 {
5801 // See above comment on the `warprings` range check.
5802 1121 bool keep_data_before = keepdata;
5803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1121 times.
1121 keepdata = keep_data_before && i < NUM_WARP_RINGS;
5804
5805
2/2
✓ Branch 0 taken 9977 times.
✓ Branch 1 taken 1121 times.
11098 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5806 {
5807
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 9081 times.
9977 if(s_version <= 3)
5808 {
5809
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,keepdata))
5810 {
5811 return qe_invalid;
5812 }
5813
5814
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 616 times.
896 if (keepdata)
5815 616 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5816 896 }
5817 else
5818 {
5819
1/2
✓ Branch 0 taken 9081 times.
✗ Branch 1 not taken.
9081 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,keepdata))
5820 {
5821 return qe_invalid;
5822 }
5823 }
5824 9977 }
5825
5826
2/2
✓ Branch 0 taken 9977 times.
✓ Branch 1 taken 1121 times.
11098 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5827 {
5828
1/2
✓ Branch 0 taken 9977 times.
✗ Branch 1 not taken.
9977 if(!p_getc(&temp_misc.warp[i].scr[j],f,keepdata))
5829 {
5830 return qe_invalid;
5831 }
5832 9977 }
5833
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1121 times.
1121 if(!p_getc(&temp_misc.warp[i].size,f,keepdata))
5835 {
5836 return qe_invalid;
5837 }
5838
5839
2/2
✓ Branch 0 taken 1089 times.
✓ Branch 1 taken 32 times.
1121 if(Header->zelda_version < 0x193)
5840 {
5841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,keepdata))
5842 {
5843 return qe_invalid;
5844 }
5845 32 }
5846
5847 1121 keepdata = keep_data_before;
5848 1121 }
5849
5850 //palette cycles
5851
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5852 {
5853
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5854 {
5855
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5856 {
5857 3072 temp_misc.cycles[i][j].first=0;
5858 3072 temp_misc.cycles[i][j].count=0;
5859 3072 temp_misc.cycles[i][j].speed=0;
5860 3072 }
5861 1024 }
5862
5863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5864 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5865 {
5866 4 palcycles=16;
5867 4 }
5868
5869
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5870 {
5871
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5872 {
5873
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5874 {
5875 return qe_invalid;
5876 }
5877
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5879 {
5880 return qe_invalid;
5881 }
5882
5883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5884 {
5885 return qe_invalid;
5886 }
5887 192 }
5888 64 }
5889 4 }
5890
5891 //Wind warps are now just another warp ring.
5892
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version <= 5)
5893 {
5894
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5895 {
5896
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5897 {
5898 return qe_invalid;
5899 }
5900 5 }
5901
5902
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5903 {
5904 return qe_invalid;
5905 }
5906
5907
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5908 {
5909
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5910 {
5911
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5912 {
5913 return qe_invalid;
5914 }
5915
5916 79 temp_misc.warp[8].dmap[i]=tempbyte;
5917 79 }
5918 else
5919 {
5920 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5921 {
5922 return qe_invalid;
5923 }
5924 }
5925
5926
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5927 {
5928 return qe_invalid;
5929 }
5930
5931 79 temp_misc.warp[8].size = 9;
5932
5933
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5934 {
5935 if(!p_getc(&tempbyte,f,true))
5936 {
5937 return qe_invalid;
5938 }
5939 }
5940 79 }
5941 9 }
5942
5943
5944 //triforce pieces
5945
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 115 times.
1035 for(int32_t i=0; i<triforces; i++)
5946 {
5947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 920 times.
920 if(!p_getc(&temp_misc.triforce[i],f,true))
5948 {
5949 return qe_invalid;
5950 }
5951 920 }
5952
5953 //misc color data
5954
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<3)
5955 {
5956
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5957 {
5958 return qe_invalid;
5959 }
5960
5961
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5962 {
5963 return qe_invalid;
5964 }
5965
5966
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5967 {
5968 return qe_invalid;
5969 }
5970
5971
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5972 {
5973 return qe_invalid;
5974 }
5975
5976
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5977 {
5978 return qe_invalid;
5979 }
5980
5981
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5982 {
5983 return qe_invalid;
5984 }
5985
5986
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5987 {
5988 return qe_invalid;
5989 }
5990
5991
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5992 {
5993 return qe_invalid;
5994 }
5995
5996
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5997 {
5998 return qe_invalid;
5999 }
6000
6001
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
6002 {
6003 return qe_invalid;
6004 }
6005
6006
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
6007 {
6008 return qe_invalid;
6009 }
6010
6011
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
6012 {
6013 return qe_invalid;
6014 }
6015
6016
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
6017 {
6018 return qe_invalid;
6019 }
6020
6021
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
6022 {
6023 return qe_invalid;
6024 }
6025
6026
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
6027 {
6028 return qe_invalid;
6029 }
6030
6031
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
6032 {
6033 return qe_invalid;
6034 }
6035
6036
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
6037 {
6038 return qe_invalid;
6039 }
6040
6041
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
6042 {
6043 return qe_invalid;
6044 }
6045
6046
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
6047 {
6048 return qe_invalid;
6049 }
6050
6051
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
6052 {
6053 return qe_invalid;
6054 }
6055
6056
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
6057 {
6058 return qe_invalid;
6059 }
6060
6061
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
6062 {
6063 return qe_invalid;
6064 }
6065
6066
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
6067 {
6068 return qe_invalid;
6069 }
6070
6071
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
6072 {
6073 return qe_invalid;
6074 }
6075
6076
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
6077 {
6078 return qe_invalid;
6079 }
6080
6081
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
6082 {
6083 return qe_invalid;
6084 }
6085
6086
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
6087 {
6088 return qe_invalid;
6089 }
6090
6091 9 temp_misc.colors.msgtext = 0x01;
6092
6093
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
6094 {
6095
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6096 {
6097
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6098 {
6099 return qe_invalid;
6100 }
6101 28 }
6102 4 }
6103
6104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6105 {
6106 for(int32_t i=0; i<256; i++)
6107 {
6108 if(!p_getc(&tempbyte,f,true))
6109 {
6110 return qe_invalid;
6111 }
6112 }
6113 }
6114
6115
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6116 {
6117 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6118 {
6119 return qe_invalid;
6120 }
6121 }
6122
6123 //save game icons
6124
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6126 {
6127 4 icons=3;
6128 4 }
6129
6130
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6131 {
6132
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6133 {
6134 return qe_invalid;
6135 }
6136 32 }
6137 9 }
6138
6139
2/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115 if((Header->zelda_version < 0x192)||
6140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6141 {
6142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6143 {
6144 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6145 4 }
6146
6147 4 return 0;
6148 }
6149
6150 //pond information
6151
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(Header->zelda_version < 0x193)
6152 {
6153 if((Header->zelda_version == 0x192)&&(Header->build<146))
6154 {
6155 pondsize=25;
6156 }
6157
6158 for(int32_t i=0; i<ponds; i++)
6159 {
6160 for(int32_t j=0; j<pondsize; j++)
6161 {
6162 if(!p_getc(&tempbyte,f,true))
6163 {
6164 return qe_invalid;
6165
6166 }
6167 }
6168 }
6169 }
6170
6171 //end string
6172
1/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if((Header->zelda_version < 0x192)||
6173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6174 {
6175 if(!p_getc(&tempbyte,f,true))
6176 {
6177 return qe_invalid;
6178 }
6179
6180 temp_misc.endstring=tempbyte;
6181
6182 if(!p_getc(&tempbyte,f,true))
6183 {
6184 return qe_invalid;
6185 }
6186 }
6187 else
6188 {
6189
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&temp_misc.endstring,f,true))
6190 {
6191 return qe_invalid;
6192 }
6193 }
6194
6195 //expansion
6196
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(Header->zelda_version < 0x193)
6197 {
6198 if((Header->zelda_version == 0x192)&&(Header->build<73))
6199 {
6200 expansionsize=99*2;
6201 }
6202
6203 for(int32_t i=0; i<expansionsize; i++)
6204 {
6205 if(!p_getc(&tempbyte,f,true))
6206 {
6207 return qe_invalid;
6208 }
6209 }
6210 }
6211 //shops v8
6212
6213
6214
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if(s_version >= 8)
6215 {
6216
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 30 times.
462 for(int32_t i=0; i<shops; i++)
6217 {
6218
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 432 times.
1728 for(int32_t j=0; j<3; j++)
6219 {
6220
1/2
✓ Branch 0 taken 1296 times.
✗ Branch 1 not taken.
1296 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6221 return qe_invalid;
6222 1296 }
6223 432 }
6224 30 }
6225
6226 111 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6227 111 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6228 111 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6229
6230 //v9 includes quest misc[32]
6231
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if(s_version >= 9)
6232 {
6233
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 30 times.
990 for ( int32_t q = 0; q < 32; q++ )
6234 {
6235
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6236 return qe_invalid;
6237 960 }
6238
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 30 times.
990 for ( int32_t q = 0; q < 32; q++ )
6239 {
6240
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 960 times.
123840 for ( int32_t j = 0; j < 128; j++ )
6241
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6242 return qe_invalid;
6243 960 }
6244 30 }
6245
6246
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(s_version >= 11 )
6247 {
6248
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6249 return qe_invalid;
6250 30 }
6251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 else if(s_version < 11 )
6252 {
6253 81 temp_misc.zscript_last_compiled_version = -1;
6254 81 }
6255
6256 111 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6257
6258
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(s_version >= 12)
6259 {
6260 byte spr;
6261
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t q = 0; q < sprMAX; ++q)
6262 {
6263
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&spr,f,true))
6264 return qe_invalid;
6265 7680 temp_misc.sprites[q] = spr;
6266 7680 }
6267 30 }
6268 else
6269 {
6270 81 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6271 //temp_misc.sprites[sprFALL] = ;
6272 }
6273
6274
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(s_version >= 13)
6275 {
6276
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 30 times.
1950 for(size_t q = 0; q < 64; ++q)
6277 {
6278 1920 bottletype* bt = &(temp_misc.bottle_types[q]);
6279
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!pfread(bt->name, 32, f, true))
6280 return qe_invalid;
6281
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 for(size_t j = 0; j < 3; ++j)
6282 {
6283
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if (!p_getc(&(bt->counter[j]), f, true))
6284 return qe_invalid;
6285
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if (!p_igetw(&(bt->amount[j]), f, true))
6286 return qe_invalid;
6287 5760 }
6288
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!p_getc(&(bt->flags), f, true))
6289 return qe_invalid;
6290
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if (!p_getc(&(bt->next_type), f, true))
6291 return qe_invalid;
6292 1920 }
6293
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(size_t q = 0; q < 256; ++q)
6294 {
6295 7680 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6296
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if (!pfread(bst->name, 32, f, true))
6297 return qe_invalid;
6298
2/2
✓ Branch 0 taken 23040 times.
✓ Branch 1 taken 7680 times.
30720 for(size_t j = 0; j < 3; ++j)
6299 {
6300
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_getc(&(bst->fill[j]), f, true))
6301 return qe_invalid;
6302
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->comb[j]), f, true))
6303 return qe_invalid;
6304
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_getc(&(bst->cset[j]), f, true))
6305 return qe_invalid;
6306
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->price[j]), f, true))
6307 return qe_invalid;
6308
1/2
✓ Branch 0 taken 23040 times.
✗ Branch 1 not taken.
23040 if (!p_igetw(&(bst->str[j]), f, true))
6309 return qe_invalid;
6310 23040 }
6311 7680 }
6312 30 }
6313 else
6314 {
6315
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 81 times.
5265 for(size_t q = 0; q < 64; ++q)
6316 5184 temp_misc.bottle_types[q].clear();
6317
2/2
✓ Branch 0 taken 20736 times.
✓ Branch 1 taken 81 times.
20817 for(size_t q = 0; q < 256; ++q)
6318 20736 temp_misc.bottle_shop_types[q].clear();
6319 }
6320
6321
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(s_version >= 14)
6322 {
6323 byte msfx;
6324
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t q = 0; q < sfxMAX; ++q)
6325 {
6326
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&msfx,f,true))
6327 return qe_invalid;
6328 7680 temp_misc.miscsfx[q] = msfx;
6329 7680 }
6330 30 }
6331 else
6332 {
6333 81 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6334 81 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6335 81 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6336 }
6337
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if(s_version < 15)
6338 {
6339 81 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6340 81 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6341 81 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6342 81 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6343 81 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6344 81 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6345 81 }
6346
6347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(keepdata==true)
6348 {
6349 111 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6350 111 }
6351
6352 111 return 0;
6353 115 }
6354
6355 extern char *item_string[ITEMCNT];
6356 extern const char *old_item_string[iLast];
6357 extern char *weapon_string[WPNCNT];
6358 extern const char *old_weapon_string[wLast];
6359
6360 115 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6361 {
6362 byte padding;
6363 int32_t dummy;
6364 115 word items_to_read=MAXITEMS;
6365 itemdata tempitem;
6366 115 word s_version=0, s_cversion=0;
6367 word dummy_word;
6368
6369
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(version < 0x186)
6370 {
6371 items_to_read=64;
6372 }
6373
6374
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(version > 0x192)
6375 {
6376 111 items_to_read=0;
6377
6378 //section version info
6379
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
6380 {
6381 return qe_invalid;
6382 }
6383
6384 111 FFCore.quest_format[vItems] = s_version;
6385
6386 //al_trace("Items version %d\n", s_version);
6387
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_cversion,f,true))
6388 {
6389 return qe_invalid;
6390 }
6391
6392 //section size
6393
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
6394 {
6395 return qe_invalid;
6396 }
6397
6398 //finally... section data
6399
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&items_to_read,f,true))
6400 {
6401 return qe_invalid;
6402 }
6403
6404
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 if (!(items_to_read >= 0 && items_to_read <= ITEMCNT))
6405 {
6406 return qe_invalid;
6407 }
6408 111 }
6409
6410
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version>1)
6411 {
6412
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i=0; i<items_to_read; i++)
6413 {
6414 char tempname[64];
6415
6416
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!pfread(tempname, 64, f, keepdata))
6417 {
6418 return qe_invalid;
6419 }
6420
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(keepdata)
6422 {
6423 27136 item_string[i][0] = '\0';
6424 27136 strncat(item_string[i], tempname, 64 - 1);
6425 27136 }
6426 27136 }
6427 106 }
6428 else
6429 {
6430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6431 {
6432
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6433 {
6434 2304 reset_itemname(i);
6435 2304 }
6436 9 }
6437 }
6438
6439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata)
6440 {
6441
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<MAXITEMS; i++)
6442 {
6443 29440 itemdata& id = itemsbuf[i];
6444 29440 memset(&id, 0, sizeof(itemdata));
6445 29440 id.count=-1;
6446 29440 id.playsound=WAV_SCALE;
6447 29440 reset_itembuf(&id,i);
6448 29440 }
6449 115 }
6450
6451
2/2
✓ Branch 0 taken 28510 times.
✓ Branch 1 taken 115 times.
28625 for(int32_t i=0; i<items_to_read; i++)
6452 {
6453 28510 memset(&tempitem, 0, sizeof(itemdata));
6454 28510 reset_itembuf(&tempitem,i);
6455
6456
6457
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 20830 times.
28510 if ( s_version > 35 ) //expanded tiles
6458 {
6459
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tile,f,true))
6460 {
6461 return qe_invalid;
6462 }
6463 7680 }
6464 else
6465 {
6466
1/2
✓ Branch 0 taken 20830 times.
✗ Branch 1 not taken.
20830 if(!p_igetw(&tempitem.tile,f,true))
6467 {
6468 return qe_invalid;
6469 }
6470 }
6471
6472
1/2
✓ Branch 0 taken 28510 times.
✗ Branch 1 not taken.
28510 if(!p_getc(&tempitem.misc_flags,f,true))
6473 {
6474 return qe_invalid;
6475 }
6476
6477
1/2
✓ Branch 0 taken 28510 times.
✗ Branch 1 not taken.
28510 if(!p_getc(&tempitem.csets,f,true))
6478 {
6479 return qe_invalid;
6480 }
6481
6482
1/2
✓ Branch 0 taken 28510 times.
✗ Branch 1 not taken.
28510 if(!p_getc(&tempitem.frames,f,true))
6483 {
6484 return qe_invalid;
6485 }
6486
6487
1/2
✓ Branch 0 taken 28510 times.
✗ Branch 1 not taken.
28510 if(!p_getc(&tempitem.speed,f,true))
6488 {
6489 return qe_invalid;
6490 }
6491
6492
1/2
✓ Branch 0 taken 28510 times.
✗ Branch 1 not taken.
28510 if(!p_getc(&tempitem.delay,f,true))
6493 {
6494 return qe_invalid;
6495 }
6496
6497
2/2
✓ Branch 0 taken 27486 times.
✓ Branch 1 taken 1024 times.
28510 if(version < 0x193)
6498 {
6499
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6505 {
6506
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6507 {
6508 case iShield:
6509 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6510 4 break;
6511
6512 case iMShield:
6513 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6514 4 break;
6515
6516 default:
6517 1016 tempitem.ltm=0;
6518 1016 break;
6519 }
6520
6521 1024 tempitem.count=-1;
6522 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6523 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6524 1024 tempitem.family=0xFF;
6525 1024 tempitem.playsound=WAV_SCALE;
6526 1024 reset_itembuf(&tempitem,i);
6527
6528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6529 {
6530 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6531 1024 }
6532
6533 1024 continue;
6534 }
6535 }
6536
6537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27486 times.
27486 if(!p_igetl(&tempitem.ltm,f,true))
6538 {
6539 return qe_invalid;
6540 }
6541
6542
1/2
✓ Branch 0 taken 27486 times.
✗ Branch 1 not taken.
27486 if(version < 0x193)
6543 {
6544 for(int32_t q=0; q<12; q++)
6545 {
6546 if(!p_getc(&padding,f,true))
6547 {
6548 return qe_invalid;
6549 }
6550 }
6551 }
6552
6553
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 350 times.
27486 if(s_version>1)
6554 {
6555
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19456 times.
27136 if ( s_version >= 31 )
6556 {
6557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.family,f,true))
6558 {
6559 return qe_invalid;
6560 }
6561 7680 }
6562 else
6563 {
6564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.family,f,true))
6565 {
6566 return qe_invalid;
6567 }
6568 }
6569
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version < 16)
6570 if(tempitem.family == 0xFF)
6571 tempitem.family = itype_misc;
6572
6573
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.fam_type,f,true))
6574 {
6575 return qe_invalid;
6576 }
6577
6578
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version>5)
6579 {
6580
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19456 times.
27136 if(s_version>=31)
6581 {
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.power,f,true))
6583 {
6584 return qe_invalid;
6585 }
6586 7680 }
6587 else
6588 {
6589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.power,f,true))
6590 {
6591 return qe_invalid;
6592 }
6593 }
6594
6595 //converted flags from 16b to 32b -Z
6596
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version < 41 )
6597 {
6598
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&tempitem.flags,f,true))
6599 {
6600 return qe_invalid;
6601 }
6602 19456 }
6603 else
6604 {
6605
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.flags,f,true))
6606 {
6607 return qe_invalid;
6608 }
6609 }
6610 27136 }
6611 else
6612 {
6613 //tempitem.power = tempitem.fam_type;
6614 char tempchar;
6615
6616 if(!p_getc(&tempchar,f,true))
6617 {
6618 return qe_invalid;
6619 }
6620
6621 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6622 }
6623
6624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetw(&tempitem.script,f,true))
6625 {
6626 return qe_invalid;
6627 }
6628
6629
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version<=3)
6630 {
6631 if(tempitem.script > NUMSCRIPTITEM)
6632 {
6633 tempitem.script = 0;
6634 }
6635 }
6636
6637
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.count,f,true))
6638 {
6639 return qe_invalid;
6640 }
6641
6642
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetw(&tempitem.amount,f,true))
6643 {
6644 return qe_invalid;
6645 }
6646
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetw(&tempitem.collect_script,f,true))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version<=3)
6653 {
6654 if(tempitem.collect_script > NUMSCRIPTITEM)
6655 {
6656 tempitem.collect_script = 0;
6657 }
6658 }
6659
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetw(&tempitem.setmax,f,true))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetw(&tempitem.max,f,true))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_getc(&tempitem.playsound,f,true))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
2/2
✓ Branch 0 taken 217088 times.
✓ Branch 1 taken 27136 times.
244224 for(int32_t j=0; j<8; j++)
6676 {
6677
1/2
✓ Branch 0 taken 217088 times.
✗ Branch 1 not taken.
217088 if(!p_igetl(&tempitem.initiald[j],f,true))
6678 {
6679 return qe_invalid;
6680 }
6681 217088 }
6682
6683
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 27136 times.
81408 for(int32_t j=0; j<2; j++)
6684 {
6685
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&tempitem.initiala[j],f,true))
6686 {
6687 return qe_invalid;
6688 }
6689 54272 }
6690
6691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(s_version>4)
6692 {
6693
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version>5)
6694 {
6695
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn,f,true))
6696 {
6697 return qe_invalid;
6698 }
6699
6700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_getc(&tempitem.wpn2,f,true))
6701 {
6702 return qe_invalid;
6703 }
6704
6705
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn3,f,true))
6706 {
6707 return qe_invalid;
6708 }
6709
6710
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn4,f,true))
6711 {
6712 return qe_invalid;
6713 }
6714
6715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(s_version>=15)
6716 {
6717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_getc(&tempitem.wpn5,f,true))
6718 {
6719 return qe_invalid;
6720 }
6721
6722
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn6,f,true))
6723 {
6724 return qe_invalid;
6725 }
6726
6727
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn7,f,true))
6728 {
6729 return qe_invalid;
6730 }
6731
6732
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn8,f,true))
6733 {
6734 return qe_invalid;
6735 }
6736
6737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_getc(&tempitem.wpn9,f,true))
6738 {
6739 return qe_invalid;
6740 }
6741
6742
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.wpn10,f,true))
6743 {
6744 return qe_invalid;
6745 }
6746 27136 }
6747
6748
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.pickup_hearts,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752
6753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(s_version<15)
6754 {
6755 if(!p_igetw(&dummy_word,f,true))
6756 {
6757 return qe_invalid;
6758 }
6759
6760 tempitem.misc1=dummy_word;
6761
6762 if(!p_igetw(&dummy_word,f,true))
6763 {
6764 return qe_invalid;
6765 }
6766
6767 tempitem.misc2=dummy_word;
6768 }
6769 else
6770 {
6771
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc1,f,true))
6772 {
6773 return qe_invalid;
6774 }
6775
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetl(&tempitem.misc2,f,true))
6777 {
6778 return qe_invalid;
6779 }
6780
6781 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6782
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(s_version<24)
6783 {
6784 if(tempitem.family==itype_shield)
6785 {
6786 tempitem.misc1|=shSCRIPT;
6787 }
6788 }
6789 }
6790
6791
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if(s_version < 53)
6792 {
6793 byte tempbyte;
6794
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempbyte,f,true))
6795 {
6796 return qe_invalid;
6797 }
6798 19456 tempitem.cost_amount[0] = tempbyte;
6799 19456 }
6800 else
6801 {
6802
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < 2; ++q)
6803 {
6804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6805 {
6806 return qe_invalid;
6807 }
6808 15360 }
6809 }
6810 27136 }
6811 else
6812 {
6813 char tempchar;
6814
6815 if(!p_getc(&tempchar,f,true))
6816 {
6817 return qe_invalid;
6818 }
6819
6820 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6821 }
6822
6823 // June 2007: more misc. attributes
6824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(s_version>=12)
6825 {
6826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(s_version<15)
6827 {
6828 if(!p_igetw(&dummy_word,f,true))
6829 {
6830 return qe_invalid;
6831 }
6832
6833 tempitem.misc3=dummy_word;
6834
6835 if(!p_igetw(&dummy_word,f,true))
6836 {
6837 return qe_invalid;
6838 }
6839
6840 tempitem.misc4=dummy_word;
6841 }
6842 else
6843 {
6844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetl(&tempitem.misc3,f,true))
6845 {
6846 return qe_invalid;
6847 }
6848
6849
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc4,f,true))
6850 {
6851 return qe_invalid;
6852 }
6853
6854
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc5,f,true))
6855 {
6856 return qe_invalid;
6857 }
6858
6859
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc6,f,true))
6860 {
6861 return qe_invalid;
6862 }
6863
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetl(&tempitem.misc7,f,true))
6865 {
6866 return qe_invalid;
6867 }
6868
6869
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc8,f,true))
6870 {
6871 return qe_invalid;
6872 }
6873
6874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(!p_igetl(&tempitem.misc9,f,true))
6875 {
6876 return qe_invalid;
6877 }
6878
6879
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_igetl(&tempitem.misc10,f,true))
6880 {
6881 return qe_invalid;
6882 }
6883 }
6884
6885
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!p_getc(&tempitem.usesound,f,true))
6886 {
6887 return qe_invalid;
6888 }
6889
6890
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 19456 times.
27136 if(s_version >= 49)
6891 {
6892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.usesound2,f,true))
6893 {
6894 return qe_invalid;
6895 }
6896 7680 }
6897 19456 else tempitem.usesound2 = 0;
6898
6899
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
27136 if(s_version < 50 && tempitem.family == itype_mirror)
6900 {
6901 //Split continue/dmap warp effect/sfx, port for old
6902 tempitem.misc2 = tempitem.misc1;
6903 tempitem.usesound2 = tempitem.usesound;
6904 }
6905 27136 }
6906 27136 }
6907
6908
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6909 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.useweapon,f,true))
6911 {
6912 return qe_invalid;
6913 }
6914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.usedefence,f,true))
6915 {
6916 return qe_invalid;
6917 }
6918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weaprange,f,true))
6919 {
6920 return qe_invalid;
6921 }
6922
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weapduration,f,true))
6923 {
6924 return qe_invalid;
6925 }
6926
2/2
✓ Branch 0 taken 76800 times.
✓ Branch 1 taken 7680 times.
84480 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6927 {
6928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76800 times.
76800 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6929 {
6930 return qe_invalid;
6931 }
6932 76800 }
6933 7680 }
6934
6935
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6936 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6937
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.duplicates,f,true))
6938 {
6939 return qe_invalid;
6940 }
6941
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 7680 times.
69120 for ( int32_t q = 0; q < INITIAL_D; q++ )
6942 {
6943
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6944 {
6945 return qe_invalid;
6946 }
6947 61440 }
6948
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for ( int32_t q = 0; q < INITIAL_A; q++ )
6949 {
6950
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6951 {
6952 return qe_invalid;
6953 }
6954 15360 }
6955
6956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_getc(&tempitem.drawlayer,f,true))
6957 {
6958 return qe_invalid;
6959 }
6960
6961
6962
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hxofs,f,true))
6963 {
6964 return qe_invalid;
6965 }
6966
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hyofs,f,true))
6967 {
6968 return qe_invalid;
6969 }
6970
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hxsz,f,true))
6971 {
6972 return qe_invalid;
6973 }
6974
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.hysz,f,true))
6975 {
6976 return qe_invalid;
6977 }
6978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.hzsz,f,true))
6979 {
6980 return qe_invalid;
6981 }
6982
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.xofs,f,true))
6983 {
6984 return qe_invalid;
6985 }
6986
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.yofs,f,true))
6987 {
6988 return qe_invalid;
6989 }
6990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6991 {
6992 return qe_invalid;
6993 }
6994
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6995 {
6996 return qe_invalid;
6997 }
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6999 {
7000 return qe_invalid;
7001 }
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hysz,f,true))
7003 {
7004 return qe_invalid;
7005 }
7006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_hzsz,f,true))
7007 {
7008 return qe_invalid;
7009 }
7010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weap_xofs,f,true))
7011 {
7012 return qe_invalid;
7013 }
7014
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_yofs,f,true))
7015 {
7016 return qe_invalid;
7017 }
7018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetw(&tempitem.weaponscript,f,true))
7019 {
7020 return qe_invalid;
7021 }
7022
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.wpnsprite,f,true))
7023 {
7024 return qe_invalid;
7025 }
7026 7680 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7027
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < num_cost_tmr; ++q)
7028 {
7029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
7030 {
7031 return qe_invalid;
7032 }
7033 15360 }
7034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 for(auto q = num_cost_tmr; q < 2; ++q)
7035 tempitem.magiccosttimer[q] = 0;
7036 7680 }
7037
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7038 {
7039 //Item Size FLags, TileWidth, TileHeight
7040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
7041 {
7042 return qe_invalid;
7043 }
7044
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tilew,f,true))
7045 {
7046 return qe_invalid;
7047 }
7048
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.tileh,f,true))
7049 {
7050 return qe_invalid;
7051 }
7052 7680 }
7053
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 29 ) //! More new vars.
7054 {
7055 //Item Size FLags, TileWidth, TileHeight
7056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
7057 {
7058 return qe_invalid;
7059 }
7060
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_tilew,f,true))
7061 {
7062 return qe_invalid;
7063 }
7064
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.weap_tileh,f,true))
7065 {
7066 return qe_invalid;
7067 }
7068 7680 }
7069
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 30 ) //! More new vars.
7070 {
7071 //Pickup Type
7072
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempitem.pickup,f,true))
7073 {
7074 return qe_invalid;
7075 }
7076 7680 }
7077
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 32 ) //! More new vars.
7078 {
7079 //Pickup Type
7080
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempitem.pstring,f,true))
7081 {
7082 return qe_invalid;
7083 }
7084 7680 }
7085
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 33 ) //! More new vars.
7086 {
7087 //Pickup Type
7088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
7089 {
7090 return qe_invalid;
7091 }
7092 7680 }
7093
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 34 ) //! cost counter
7094 {
7095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
7680 if(s_version < 53)
7096 {
7097 if(!p_getc(&tempitem.cost_counter[0],f,true))
7098 {
7099 return qe_invalid;
7100 }
7101 }
7102 else
7103 {
7104
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for(auto q = 0; q < 2; ++q)
7105 {
7106
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&tempitem.cost_counter[q],f,true))
7107 {
7108 return qe_invalid;
7109 }
7110 15360 }
7111 }
7112 7680 }
7113
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 44 ) //! sprite scripts
7114 {
7115
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 7680 times.
69120 for ( int32_t q = 0; q < 8; q++ )
7116 {
7117
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7118 {
7119
1/2
✓ Branch 0 taken 3993600 times.
✗ Branch 1 not taken.
3993600 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7120 {
7121 return qe_invalid;
7122 }
7123 3993600 }
7124
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7125 {
7126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3993600 times.
3993600 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7127 {
7128 return qe_invalid;
7129 }
7130 3993600 }
7131
2/2
✓ Branch 0 taken 3993600 times.
✓ Branch 1 taken 61440 times.
4055040 for ( int32_t w = 0; w < 65; w++ )
7132 {
7133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3993600 times.
3993600 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7134 {
7135 return qe_invalid;
7136 }
7137 3993600 }
7138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61440 times.
61440 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7139 {
7140 return qe_invalid;
7141 }
7142
7143 61440 }
7144
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 7680 times.
23040 for ( int32_t q = 0; q < 2; q++ )
7145 {
7146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15360 times.
15360 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7147 {
7148 return qe_invalid;
7149 }
7150 15360 }
7151 //Pickup Type
7152
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempitem.sprite_script,f,true))
7153 {
7154 return qe_invalid;
7155 }
7156 7680 }
7157
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7680 times.
27136 if ( s_version >= 48 ) //! pickup flags
7158 {
7159
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7160 {
7161 return qe_invalid;
7162 }
7163 7680 }
7164
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 6144 times.
27136 if ( s_version >= 57 )
7165 {
7166 6144 std::string str;
7167
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 6144 times.
✗ Branch 3 not taken.
6144 if(!p_getcstr(&str,f,true))
7168 return qe_invalid;
7169 6144 strncpy(tempitem.display_name,str.c_str(),255);
7170
1/3
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6144 }
7171 27136 }
7172 else
7173 {
7174 350 tempitem.count=-1;
7175 350 tempitem.family=itype_misc;
7176 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7177 350 tempitem.playsound=WAV_SCALE;
7178 350 reset_itembuf(&tempitem,i);
7179 }
7180
7181
1/2
✓ Branch 0 taken 27486 times.
✗ Branch 1 not taken.
27486 if(keepdata==true)
7182 {
7183 27486 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7184 27486 }
7185 else if(zgpmode)
7186 {
7187 itemsbuf[i].tile=tempitem.tile;
7188 itemsbuf[i].misc_flags=tempitem.misc_flags;
7189 itemsbuf[i].csets=tempitem.csets;
7190 itemsbuf[i].frames=tempitem.frames;
7191 itemsbuf[i].speed=tempitem.speed;
7192 itemsbuf[i].delay=tempitem.delay;
7193 itemsbuf[i].ltm=tempitem.ltm;
7194 }
7195 27486 }
7196
7197 //////////////////////////////////////////////////////
7198 // Now do any updates because of new item additions
7199 // (These can't be done above because items_to_read
7200 // might be too low.)
7201 //////////////////////////////////////////////////////
7202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
7203 {
7204
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<MAXITEMS; i++)
7205 {
7206 29440 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7207
7208 //Account for older quests that didn't have an actual item for the used letter
7209
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 27136 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29440 if(s_version < 2 && i==iLetterUsed)
7210 {
7211 9 reset_itembuf(&tempitem, iLetterUsed);
7212 9 strcpy(item_string[i],old_item_string[i]);
7213 9 tempitem.tile = itemsbuf[iLetter].tile;
7214 9 tempitem.csets = itemsbuf[iLetter].csets;
7215 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7216 9 tempitem.frames = itemsbuf[iLetter].frames;
7217 9 tempitem.speed = itemsbuf[iLetter].speed;
7218 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7219 9 }
7220
7221
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 3)
7222 {
7223
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7224 {
7225 case iRocsFeather:
7226 case iHoverBoots:
7227 case iSpinScroll:
7228 case iL2SpinScroll:
7229 case iCrossScroll:
7230 case iQuakeScroll:
7231 case iL2QuakeScroll:
7232 case iWhispRing:
7233 case iL2WhispRing:
7234 case iChargeRing:
7235 case iL2ChargeRing:
7236 case iPerilScroll:
7237 case iWalletL3:
7238 case iQuiverL4:
7239 case iBombBagL4:
7240 case iBracelet:
7241 case iL2Bracelet:
7242 case iOldGlove:
7243 case iL2Ladder:
7244 case iWealthMedal:
7245 case iL2WealthMedal:
7246 case iL3WealthMedal:
7247 198 reset_itembuf(&tempitem, i);
7248 198 strcpy(item_string[i],old_item_string[i]);
7249 198 break;
7250
7251 case iSShield:
7252 9 reset_itembuf(&tempitem, i);
7253 9 strcpy(item_string[i],old_item_string[i]);
7254 9 strcpy(item_string[iShield],old_item_string[iShield]);
7255 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7256 9 break;
7257 }
7258 2304 }
7259
7260
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 5)
7261 {
7262
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7263 {
7264 case iHeartRing:
7265 case iL2HeartRing:
7266 case iL3HeartRing:
7267 case iMagicRing:
7268 case iL2MagicRing:
7269 case iL3MagicRing:
7270 case iL4MagicRing:
7271 63 reset_itembuf(&tempitem, i);
7272 63 strcpy(item_string[i],old_item_string[i]);
7273 63 break;
7274 }
7275 2304 }
7276
7277
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7278 {
7279
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7280 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7281
7282
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7283 {
7284 case iTriforce:
7285 9 tempitem.fam_type=1;
7286 9 break;
7287
7288 case iBigTri:
7289 9 tempitem.fam_type=0;
7290 9 break;
7291
7292 case iBombs:
7293 9 tempitem.fam_type=i_bomb;
7294 9 tempitem.power=4;
7295 9 tempitem.wpn=wBOMB;
7296 9 tempitem.wpn2=wBOOM;
7297 9 tempitem.misc1 = 50;
7298
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7300
7301 9 break;
7302
7303 case iSBomb:
7304 9 tempitem.fam_type=i_sbomb;
7305 9 tempitem.power=16;
7306 9 tempitem.wpn=wSBOMB;
7307 9 tempitem.wpn2=wSBOOM;
7308 9 tempitem.misc1 = 50;
7309
7310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7311
7312 9 break;
7313
7314 case iBook:
7315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7316 tempitem.wpn = wFIREMAGIC;
7317
7318 9 break;
7319
7320 case iSArrow:
7321 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7322 9 tempitem.power=4;
7323 9 tempitem.flags|=ITEM_GAMEDATA;
7324 9 tempitem.wpn=wSARROW;
7325 9 break;
7326
7327 case iGArrow:
7328 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7329 9 tempitem.power=8;
7330 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7331 9 tempitem.wpn=wGARROW;
7332 9 break;
7333
7334 case iBrang:
7335 9 tempitem.power=0;
7336 9 tempitem.wpn=wBRANG;
7337 9 tempitem.misc1=36;
7338 9 break;
7339
7340 case iMBrang:
7341 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7342 9 tempitem.power=0;
7343 9 tempitem.wpn=wMBRANG;
7344 9 break;
7345
7346 case iFBrang:
7347 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7348 9 tempitem.power=2;
7349 9 tempitem.wpn=wFBRANG;
7350 9 break;
7351
7352 case iBoots:
7353 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7354 9 tempitem.power=7;
7355 9 break;
7356
7357 case iWand:
7358 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7359 9 tempitem.power=2;
7360 9 tempitem.wpn=wWAND;
7361 9 tempitem.wpn3=wMAGIC;
7362 9 break;
7363
7364 case iBCandle:
7365 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7366 9 tempitem.power=1;
7367 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7368 9 tempitem.wpn3=wFIRE;
7369 9 break;
7370
7371 case iRCandle:
7372 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7373 9 tempitem.power=1;
7374 9 tempitem.wpn3=wFIRE;
7375 9 break;
7376
7377 case iSword:
7378 9 tempitem.power=1;
7379 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7380 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7381 9 tempitem.wpn2=wSWORDSLASH;
7382 9 break;
7383
7384 case iWSword:
7385 9 tempitem.power=2;
7386 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7387 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7388 9 tempitem.wpn2=wWSWORDSLASH;
7389 9 break;
7390
7391 case iMSword:
7392 9 tempitem.power=4;
7393 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7394 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7395 9 tempitem.wpn2=wMSWORDSLASH;
7396 9 break;
7397
7398 case iXSword:
7399 9 tempitem.power=8;
7400 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7401 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7402 9 tempitem.wpn2=wXSWORDSLASH;
7403 9 break;
7404
7405 case iDivineProtection:
7406 9 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7407 9 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7408 9 tempitem.wpn=wDIVINEPROTECTION1A;
7409 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7410 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7411 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7412 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7413 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7414 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7415 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7416 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7417 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7418 9 tempitem.misc1=512;
7419 9 tempitem.cost_amount[0]=64;
7420 9 break;
7421
7422 case iLens:
7423 9 tempitem.misc1=60;
7424 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7425 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7426 9 break;
7427
7428 case iArrow:
7429 9 tempitem.power=2;
7430 9 tempitem.wpn=wARROW;
7431 9 break;
7432
7433 case iHoverBoots:
7434 9 tempitem.misc1=45;
7435 9 tempitem.wpn=iwHover;
7436 9 break;
7437
7438 case iDivineFire:
7439 9 tempitem.power=8;
7440 9 tempitem.wpn=wDIVINEFIRE1A;
7441 9 tempitem.wpn2=wDIVINEFIRE1B;
7442 9 tempitem.wpn3=wDIVINEFIRES1A;
7443 9 tempitem.wpn4=wDIVINEFIRES1B;
7444 9 tempitem.misc1 = 32;
7445 9 tempitem.misc2 = 200;
7446 9 tempitem.cost_amount[0]=32;
7447 9 break;
7448
7449 case iDivineEscape:
7450 9 tempitem.cost_amount[0]=32;
7451 9 break;
7452
7453 case iHookshot:
7454 9 tempitem.power=0;
7455 9 tempitem.flags&=~ITEM_FLAG1;
7456 9 tempitem.wpn=wHSHEAD;
7457 9 tempitem.wpn2=wHSCHAIN_H;
7458 9 tempitem.wpn4=wHSHANDLE;
7459 9 tempitem.wpn3=wHSCHAIN_V;
7460 9 tempitem.misc1=50;
7461 9 tempitem.misc2=100;
7462 9 break;
7463
7464 case iLongshot:
7465 9 tempitem.power=0;
7466 9 tempitem.flags&=~ITEM_FLAG1;
7467 9 tempitem.wpn=wLSHEAD;
7468 9 tempitem.wpn2=wLSCHAIN_H;
7469 9 tempitem.wpn4=wLSHANDLE;
7470 9 tempitem.wpn3=wLSCHAIN_V;
7471 9 tempitem.misc1=99;
7472 9 tempitem.misc2=100;
7473 9 break;
7474
7475 case iHammer:
7476 9 tempitem.power=4;
7477 9 tempitem.wpn=wHAMMER;
7478 9 tempitem.wpn2=iwHammerSmack;
7479 9 break;
7480
7481 case iCByrna:
7482 9 tempitem.power=1;
7483 9 tempitem.wpn=wCBYRNA;
7484 9 tempitem.wpn2=wCBYRNASLASH;
7485 9 tempitem.wpn3=wCBYRNAORB;
7486 9 tempitem.misc1=4;
7487 9 tempitem.misc2=16;
7488 9 tempitem.misc3=1;
7489 9 tempitem.cost_amount[0]=1;
7490 9 break;
7491
7492 case iWhistle:
7493 9 tempitem.wpn=wWIND;
7494 9 tempitem.misc1=3;
7495 9 tempitem.flags|=ITEM_FLAG1;
7496 9 break;
7497
7498 case iBRing:
7499 9 tempitem.power=2;
7500 9 tempitem.misc1=spBLUE;
7501 9 break;
7502
7503 case iRRing:
7504 9 tempitem.power=4;
7505 9 tempitem.misc1=spRED;
7506 9 break;
7507
7508 case iGRing:
7509 9 tempitem.power=8;
7510 9 tempitem.misc1=spGOLD;
7511 9 break;
7512
7513 case iSpinScroll:
7514 9 tempitem.power = 2;
7515 9 tempitem.misc1 = 1;
7516 9 break;
7517
7518 case iL2SpinScroll:
7519 9 tempitem.family=itype_spinscroll2;
7520 9 tempitem.fam_type=1;
7521 9 tempitem.cost_amount[0]=8;
7522 9 tempitem.power=2;
7523 9 tempitem.misc1 = 20;
7524 9 break;
7525
7526 case iQuakeScroll:
7527 9 tempitem.misc1=0x10;
7528 9 tempitem.misc2=64;
7529 9 break;
7530
7531 case iL2QuakeScroll:
7532 9 tempitem.family=itype_quakescroll2;
7533 9 tempitem.fam_type=1;
7534 9 tempitem.power = 2;
7535 9 tempitem.misc1=0x20;
7536 9 tempitem.misc2=192;
7537 9 tempitem.cost_amount[0]=8;
7538 9 break;
7539
7540 case iChargeRing:
7541 9 tempitem.misc1=64;
7542 9 tempitem.misc2=128;
7543 9 break;
7544
7545 case iL2ChargeRing:
7546 9 tempitem.misc1=32;
7547 9 tempitem.misc2=64;
7548 9 break;
7549
7550 case iOldGlove:
7551 9 tempitem.flags |= ITEM_FLAG1;
7552
7553 //fallthrough
7554 case iBombBagL4:
7555 case iWalletL3:
7556 case iQuiverL4:
7557 case iBracelet:
7558 45 tempitem.power = 1;
7559 45 break;
7560
7561 case iL2Bracelet:
7562 9 tempitem.power = 2;
7563 9 break;
7564
7565 case iMKey:
7566 9 tempitem.power=0xFF;
7567 9 tempitem.flags |= ITEM_FLAG1;
7568 9 break;
7569 }
7570 2304 }
7571
7572
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 7)
7573 {
7574
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7575 {
7576 case iStoneAgony:
7577 case iStompBoots:
7578 case iPerilRing:
7579 case iWhimsicalRing:
7580 {
7581 36 reset_itembuf(&tempitem, i);
7582 36 strcpy(item_string[i],old_item_string[i]);
7583 36 break;
7584 }
7585 }
7586 2304 }
7587
7588
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 8) // May 2007: Some corrections.
7589 {
7590
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7591 {
7592 case iMShield:
7593 9 tempitem.misc1|=shFLAME;
7594 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7595
7596
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7597 {
7598 tempitem.misc2 |= shSWORD;
7599 }
7600
7601 // fallthrough
7602 case iShield:
7603 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7604
7605 // fallthrough
7606 case iSShield:
7607 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7608
7609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7610 {
7611 tempitem.misc2 |= shROCK;
7612 }
7613
7614 27 break;
7615
7616 case iWhispRing:
7617 9 tempitem.power=1;
7618 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7619 9 tempitem.misc1 = 3;
7620 9 break;
7621
7622 case iL2WhispRing:
7623 9 tempitem.power=0;
7624 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7625 9 tempitem.misc1 = 3;
7626 9 break;
7627
7628 case iL2Ladder:
7629 case iBow:
7630 case iCByrna:
7631 27 tempitem.power = 1;
7632 27 break;
7633 }
7634 2304 }
7635
7636
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 27136 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29440 if(s_version < 9 && i==iClock)
7637 {
7638 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7639 9 }
7640
7641 //add the misc flag for bomb
7642
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 27136 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29440 if(s_version < 10 && tempitem.family == itype_bomb)
7643 {
7644 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7645 9 }
7646
7647
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 27136 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
29440 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7648 {
7649 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7650 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7651 18 }
7652
7653
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 12) // June 2007: More Misc. attributes.
7654 {
7655
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7656 {
7657 case iFBrang:
7658 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7659
7660 //fallthrough
7661 case iMBrang:
7662 18 tempitem.misc3 |= shSWORD|shMAGIC;
7663
7664 //fallthrough
7665 case iHookshot:
7666 case iLongshot:
7667 //fallthrough
7668 36 tempitem.misc3 |= shFIREBALL;
7669
7670 case iBrang:
7671 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7672 45 break;
7673 }
7674
7675
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7676 {
7677 case itype_hoverboots:
7678 9 tempitem.usesound = WAV_ZN1HOVER;
7679 9 break;
7680
7681 case itype_wand:
7682 9 tempitem.usesound = WAV_WAND;
7683 9 break;
7684
7685 case itype_book:
7686 9 tempitem.usesound = WAV_FIRE;
7687 9 break;
7688
7689 case itype_arrow:
7690 27 tempitem.usesound = WAV_ARROW;
7691 27 break;
7692
7693 case itype_hookshot:
7694 18 tempitem.usesound = WAV_HOOKSHOT;
7695 18 break;
7696
7697 case itype_brang:
7698 27 tempitem.usesound = WAV_BRANG;
7699 27 break;
7700
7701 case itype_shield:
7702 27 tempitem.usesound = WAV_CHINK;
7703 27 break;
7704
7705 case itype_sword:
7706 781 tempitem.usesound = WAV_SWORD;
7707 781 break;
7708
7709 case itype_whistle:
7710 9 tempitem.usesound = WAV_WHISTLE;
7711 9 break;
7712
7713 case itype_hammer:
7714 9 tempitem.usesound = WAV_HAMMER;
7715 9 break;
7716
7717 case itype_divinefire:
7718 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7719 9 break;
7720
7721 case itype_divineescape:
7722 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7723 9 break;
7724
7725 case itype_divineprotection:
7726 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7727 9 break;
7728
7729 case itype_bomb:
7730 case itype_sbomb:
7731 case itype_quakescroll:
7732 case itype_quakescroll2:
7733 36 tempitem.usesound = WAV_BOMB;
7734 36 break;
7735
7736 case itype_spinscroll:
7737 case itype_spinscroll2:
7738 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7739 18 break;
7740 }
7741 2304 }
7742
7743
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 13) // July 2007
7744 {
7745
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7746 {
7747 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7748 9 tempitem.power = 1;
7749 9 tempitem.flags|=ITEM_FLAG1;
7750 9 }
7751
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7752 9 tempitem.flags|=ITEM_FLAG1;
7753
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7754 {
7755 9 tempitem.flags|=ITEM_FLAG1;
7756 9 tempitem.power = 2;
7757 9 }
7758 2304 }
7759
7760
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 14) // August 2007
7761 {
7762
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7763 {
7764 18 tempitem.usesound = WAV_SCALE;
7765
7766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7767 18 tempitem.misc3=50;
7768 18 }
7769
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7770 {
7771 18 tempitem.flags |= ITEM_GAINOLD;
7772 18 }
7773 2304 }
7774
7775
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 17) // November 2007
7776 {
7777
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7778 {
7779 tempitem.wpn3 = wFIRE;
7780 }
7781
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7782 {
7783 9 tempitem.flags|=ITEM_FLAG1;
7784 9 }
7785 2304 }
7786
7787
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 18) // New Year's Eve 2007
7788 {
7789
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7790 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7791
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7792 9 tempitem.misc1 = 768; // Frames until it goes
7793
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7794 {
7795
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7796 {
7797 9 tempitem.misc2 = 1; // Cutscene 1
7798 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7799 9 }
7800 18 }
7801 2304 }
7802
7803
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 19) // January 2008
7804 {
7805
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7806 {
7807 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7808 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7809 9 }
7810 2304 }
7811
7812
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 20) // October 2008
7813 {
7814
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7815 {
7816 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7817 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7818 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7819 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7820 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7821 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7822 9 }
7823 2304 }
7824
7825
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 21) // November 2008
7826 {
7827
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7828 {
7829 tempitem.flags &= ~0x0100;
7830
7831 if(tempitem.family == itype_sword ||
7832 tempitem.family == itype_wand ||
7833 tempitem.family == itype_candle ||
7834 tempitem.family == itype_cbyrna)
7835 {
7836 tempitem.flags |= ITEM_FLAG4;
7837 }
7838 }
7839 2304 }
7840
7841
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 22) // September 2009
7842 {
7843
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7844 {
7845 18 tempitem.misc3 = tempitem.power/2;
7846 18 }
7847 2304 }
7848
7849
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 23) // March 2011
7850 {
7851
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7852 9 tempitem.wpn5 = wFIRE;
7853
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7854 9 tempitem.wpn2 = wFIRE;
7855 2304 }
7856
7857 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7858 // whether it was or not, and a lot of existing quests depended on the
7859 // incorrect behavior.
7860
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 2304 times.
29440 if(s_version < 25) // January 2012
7861 {
7862
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7863 36 tempitem.flags |= 16;
7864
7865
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7866 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7867 2304 }
7868
7869
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7870 {
7871
60/60
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 85 times.
✓ Branch 6 taken 168 times.
✓ Branch 7 taken 167 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 278 times.
✓ Branch 10 taken 252 times.
✓ Branch 11 taken 167 times.
✓ Branch 12 taken 259 times.
✓ Branch 13 taken 168 times.
✓ Branch 14 taken 84 times.
✓ Branch 15 taken 168 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 84 times.
✓ Branch 18 taken 255 times.
✓ Branch 19 taken 85 times.
✓ Branch 20 taken 86 times.
✓ Branch 21 taken 168 times.
✓ Branch 22 taken 84 times.
✓ Branch 23 taken 85 times.
✓ Branch 24 taken 84 times.
✓ Branch 25 taken 84 times.
✓ Branch 26 taken 84 times.
✓ Branch 27 taken 99 times.
✓ Branch 28 taken 84 times.
✓ Branch 29 taken 85 times.
✓ Branch 30 taken 84 times.
✓ Branch 31 taken 85 times.
✓ Branch 32 taken 168 times.
✓ Branch 33 taken 336 times.
✓ Branch 34 taken 86 times.
✓ Branch 35 taken 84 times.
✓ Branch 36 taken 152 times.
✓ Branch 37 taken 336 times.
✓ Branch 38 taken 84 times.
✓ Branch 39 taken 84 times.
✓ Branch 40 taken 84 times.
✓ Branch 41 taken 84 times.
✓ Branch 42 taken 84 times.
✓ Branch 43 taken 169 times.
✓ Branch 44 taken 168 times.
✓ Branch 45 taken 84 times.
✓ Branch 46 taken 253 times.
✓ Branch 47 taken 254 times.
✓ Branch 48 taken 340 times.
✓ Branch 49 taken 84 times.
✓ Branch 50 taken 84 times.
✓ Branch 51 taken 84 times.
✓ Branch 52 taken 84 times.
✓ Branch 53 taken 84 times.
✓ Branch 54 taken 85 times.
✓ Branch 55 taken 2368 times.
✓ Branch 56 taken 903 times.
✓ Branch 57 taken 253 times.
✓ Branch 58 taken 1047 times.
✓ Branch 59 taken 2617 times.
21760 switch(tempitem.family)
7872 {
7873 case itype_sword:
7874 {
7875 6848 tempitem.flags &= ~(ITEM_FLAG5);
7876 6848 tempitem.misc3 = 0;
7877 6848 tempitem.misc4 = 0;
7878 6848 tempitem.misc5 = 0;
7879 6848 tempitem.misc6 = 0;
7880 6848 tempitem.misc7 = 0;
7881 6848 tempitem.misc8 = 0;
7882 6848 tempitem.misc9 = 0;
7883 6848 tempitem.misc10 = 0;
7884 6848 tempitem.wpn4 = 0;
7885 6848 tempitem.wpn5 = 0;
7886 6848 tempitem.wpn6 = 0;
7887 6848 tempitem.wpn7 = 0;
7888 6848 tempitem.wpn8 = 0;
7889 6848 tempitem.wpn9 = 0;
7890 6848 tempitem.wpn10 = 0;
7891 6848 break;
7892 }
7893 case itype_brang:
7894 {
7895 253 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7896 253 tempitem.misc2 = 0;
7897 253 tempitem.misc5 = 0;
7898 253 tempitem.misc6 = 0;
7899 253 tempitem.misc7 = 0;
7900 253 tempitem.misc8 = 0;
7901 253 tempitem.misc9 = 0;
7902 253 tempitem.misc10 = 0;
7903 253 tempitem.wpn4 = 0;
7904 253 tempitem.wpn5 = 0;
7905 253 tempitem.wpn6 = 0;
7906 253 tempitem.wpn7 = 0;
7907 253 tempitem.wpn8 = 0;
7908 253 tempitem.wpn9 = 0;
7909 253 tempitem.wpn10 = 0;
7910 253 break;
7911 }
7912 case itype_arrow:
7913 {
7914 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7915 250 tempitem.misc2 = 0;
7916 250 tempitem.misc3 = 0;
7917 250 tempitem.misc4 = 0;
7918 250 tempitem.misc5 = 0;
7919 250 tempitem.misc6 = 0;
7920 250 tempitem.misc7 = 0;
7921 250 tempitem.misc8 = 0;
7922 250 tempitem.misc9 = 0;
7923 250 tempitem.misc10 = 0;
7924 250 tempitem.wpn4 = 0;
7925 250 tempitem.wpn5 = 0;
7926 250 tempitem.wpn6 = 0;
7927 250 tempitem.wpn7 = 0;
7928 250 tempitem.wpn8 = 0;
7929 250 tempitem.wpn9 = 0;
7930 250 tempitem.wpn10 = 0;
7931 250 break;
7932 }
7933 case itype_candle:
7934 {
7935 206 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7936 206 tempitem.misc1 = 0;
7937 206 tempitem.misc2 = 0;
7938 206 tempitem.misc3 = 0;
7939 206 tempitem.misc4 = 0;
7940 206 tempitem.misc5 = 0;
7941 206 tempitem.misc6 = 0;
7942 206 tempitem.misc7 = 0;
7943 206 tempitem.misc8 = 0;
7944 206 tempitem.misc9 = 0;
7945 206 tempitem.misc10 = 0;
7946 206 tempitem.wpn4 = 0;
7947 206 tempitem.wpn5 = 0;
7948 206 tempitem.wpn6 = 0;
7949 206 tempitem.wpn7 = 0;
7950 206 tempitem.wpn8 = 0;
7951 206 tempitem.wpn9 = 0;
7952 206 tempitem.wpn10 = 0;
7953 206 break;
7954 }
7955 case itype_whistle:
7956 {
7957 130 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7958 130 tempitem.misc3 = 0;
7959 130 tempitem.misc4 = 0;
7960 130 tempitem.misc5 = 0;
7961 130 tempitem.misc6 = 0;
7962 130 tempitem.misc7 = 0;
7963 130 tempitem.misc8 = 0;
7964 130 tempitem.misc9 = 0;
7965 130 tempitem.misc10 = 0;
7966 130 tempitem.wpn2 = 0;
7967 130 tempitem.wpn3 = 0;
7968 130 tempitem.wpn4 = 0;
7969 130 tempitem.wpn5 = 0;
7970 130 tempitem.wpn6 = 0;
7971 130 tempitem.wpn7 = 0;
7972 130 tempitem.wpn8 = 0;
7973 130 tempitem.wpn9 = 0;
7974 130 tempitem.wpn10 = 0;
7975 130 break;
7976 }
7977 case itype_bait:
7978 {
7979 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7980 85 tempitem.misc2 = 0;
7981 85 tempitem.misc3 = 0;
7982 85 tempitem.misc4 = 0;
7983 85 tempitem.misc5 = 0;
7984 85 tempitem.misc6 = 0;
7985 85 tempitem.misc7 = 0;
7986 85 tempitem.misc8 = 0;
7987 85 tempitem.misc9 = 0;
7988 85 tempitem.misc10 = 0;
7989 85 tempitem.wpn2 = 0;
7990 85 tempitem.wpn3 = 0;
7991 85 tempitem.wpn4 = 0;
7992 85 tempitem.wpn5 = 0;
7993 85 tempitem.wpn6 = 0;
7994 85 tempitem.wpn7 = 0;
7995 85 tempitem.wpn8 = 0;
7996 85 tempitem.wpn9 = 0;
7997 85 tempitem.wpn10 = 0;
7998 85 break;
7999 }
8000 case itype_letter:
8001 {
8002 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8003 168 tempitem.misc1 = 0;
8004 168 tempitem.misc2 = 0;
8005 168 tempitem.misc3 = 0;
8006 168 tempitem.misc4 = 0;
8007 168 tempitem.misc5 = 0;
8008 168 tempitem.misc6 = 0;
8009 168 tempitem.misc7 = 0;
8010 168 tempitem.misc8 = 0;
8011 168 tempitem.misc9 = 0;
8012 168 tempitem.misc10 = 0;
8013 168 tempitem.wpn = 0;
8014 168 tempitem.wpn2 = 0;
8015 168 tempitem.wpn3 = 0;
8016 168 tempitem.wpn4 = 0;
8017 168 tempitem.wpn5 = 0;
8018 168 tempitem.wpn6 = 0;
8019 168 tempitem.wpn7 = 0;
8020 168 tempitem.wpn8 = 0;
8021 168 tempitem.wpn9 = 0;
8022 168 tempitem.wpn10 = 0;
8023 168 break;
8024 }
8025 case itype_potion:
8026 {
8027 167 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8028 167 tempitem.misc3 = 0;
8029 167 tempitem.misc4 = 0;
8030 167 tempitem.misc5 = 0;
8031 167 tempitem.misc6 = 0;
8032 167 tempitem.misc7 = 0;
8033 167 tempitem.misc8 = 0;
8034 167 tempitem.misc9 = 0;
8035 167 tempitem.misc10 = 0;
8036 167 tempitem.wpn = 0;
8037 167 tempitem.wpn2 = 0;
8038 167 tempitem.wpn3 = 0;
8039 167 tempitem.wpn4 = 0;
8040 167 tempitem.wpn5 = 0;
8041 167 tempitem.wpn6 = 0;
8042 167 tempitem.wpn7 = 0;
8043 167 tempitem.wpn8 = 0;
8044 167 tempitem.wpn9 = 0;
8045 167 tempitem.wpn10 = 0;
8046 167 break;
8047 }
8048 case itype_wand:
8049 {
8050 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8051 99 tempitem.misc1 = 0;
8052 99 tempitem.misc2 = 0;
8053 99 tempitem.misc3 = 0;
8054 99 tempitem.misc4 = 0;
8055 99 tempitem.misc5 = 0;
8056 99 tempitem.misc6 = 0;
8057 99 tempitem.misc7 = 0;
8058 99 tempitem.misc8 = 0;
8059 99 tempitem.misc9 = 0;
8060 99 tempitem.misc10 = 0;
8061 99 tempitem.wpn4 = 0;
8062 99 tempitem.wpn5 = 0;
8063 99 tempitem.wpn6 = 0;
8064 99 tempitem.wpn7 = 0;
8065 99 tempitem.wpn8 = 0;
8066 99 tempitem.wpn9 = 0;
8067 99 tempitem.wpn10 = 0;
8068 99 break;
8069 }
8070 case itype_ring:
8071 {
8072 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8073 278 tempitem.misc2 = 0;
8074 278 tempitem.misc3 = 0;
8075 278 tempitem.misc4 = 0;
8076 278 tempitem.misc5 = 0;
8077 278 tempitem.misc6 = 0;
8078 278 tempitem.misc7 = 0;
8079 278 tempitem.misc8 = 0;
8080 278 tempitem.misc9 = 0;
8081 278 tempitem.misc10 = 0;
8082 278 tempitem.wpn = 0;
8083 278 tempitem.wpn2 = 0;
8084 278 tempitem.wpn3 = 0;
8085 278 tempitem.wpn4 = 0;
8086 278 tempitem.wpn5 = 0;
8087 278 tempitem.wpn6 = 0;
8088 278 tempitem.wpn7 = 0;
8089 278 tempitem.wpn8 = 0;
8090 278 tempitem.wpn9 = 0;
8091 278 tempitem.wpn10 = 0;
8092 278 break;
8093 }
8094 case itype_wallet:
8095 {
8096 252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8097 252 tempitem.misc3 = 0;
8098 252 tempitem.misc4 = 0;
8099 252 tempitem.misc5 = 0;
8100 252 tempitem.misc6 = 0;
8101 252 tempitem.misc7 = 0;
8102 252 tempitem.misc8 = 0;
8103 252 tempitem.misc9 = 0;
8104 252 tempitem.misc10 = 0;
8105 252 tempitem.wpn = 0;
8106 252 tempitem.wpn2 = 0;
8107 252 tempitem.wpn3 = 0;
8108 252 tempitem.wpn4 = 0;
8109 252 tempitem.wpn5 = 0;
8110 252 tempitem.wpn6 = 0;
8111 252 tempitem.wpn7 = 0;
8112 252 tempitem.wpn8 = 0;
8113 252 tempitem.wpn9 = 0;
8114 252 tempitem.wpn10 = 0;
8115 252 break;
8116 }
8117 case itype_amulet:
8118 {
8119 167 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8120 167 tempitem.misc1 = 0;
8121 167 tempitem.misc2 = 0;
8122 167 tempitem.misc3 = 0;
8123 167 tempitem.misc4 = 0;
8124 167 tempitem.misc5 = 0;
8125 167 tempitem.misc6 = 0;
8126 167 tempitem.misc7 = 0;
8127 167 tempitem.misc8 = 0;
8128 167 tempitem.misc9 = 0;
8129 167 tempitem.misc10 = 0;
8130 167 tempitem.wpn = 0;
8131 167 tempitem.wpn2 = 0;
8132 167 tempitem.wpn3 = 0;
8133 167 tempitem.wpn4 = 0;
8134 167 tempitem.wpn5 = 0;
8135 167 tempitem.wpn6 = 0;
8136 167 tempitem.wpn7 = 0;
8137 167 tempitem.wpn8 = 0;
8138 167 tempitem.wpn9 = 0;
8139 167 tempitem.wpn10 = 0;
8140 167 break;
8141 }
8142 case itype_shield:
8143 {
8144 259 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8145 259 tempitem.misc3 = 0;
8146 259 tempitem.misc4 = 0;
8147 259 tempitem.misc5 = 0;
8148 259 tempitem.misc6 = 0;
8149 259 tempitem.misc7 = 0;
8150 259 tempitem.misc8 = 0;
8151 259 tempitem.misc9 = 0;
8152 259 tempitem.misc10 = 0;
8153 259 tempitem.wpn = 0;
8154 259 tempitem.wpn2 = 0;
8155 259 tempitem.wpn3 = 0;
8156 259 tempitem.wpn4 = 0;
8157 259 tempitem.wpn5 = 0;
8158 259 tempitem.wpn6 = 0;
8159 259 tempitem.wpn7 = 0;
8160 259 tempitem.wpn8 = 0;
8161 259 tempitem.wpn9 = 0;
8162 259 tempitem.wpn10 = 0;
8163 259 break;
8164 }
8165 case itype_bow:
8166 {
8167 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8168 168 tempitem.misc1 = 0;
8169 168 tempitem.misc2 = 0;
8170 168 tempitem.misc3 = 0;
8171 168 tempitem.misc4 = 0;
8172 168 tempitem.misc5 = 0;
8173 168 tempitem.misc6 = 0;
8174 168 tempitem.misc7 = 0;
8175 168 tempitem.misc8 = 0;
8176 168 tempitem.misc9 = 0;
8177 168 tempitem.misc10 = 0;
8178 168 tempitem.wpn = 0;
8179 168 tempitem.wpn2 = 0;
8180 168 tempitem.wpn3 = 0;
8181 168 tempitem.wpn4 = 0;
8182 168 tempitem.wpn5 = 0;
8183 168 tempitem.wpn6 = 0;
8184 168 tempitem.wpn7 = 0;
8185 168 tempitem.wpn8 = 0;
8186 168 tempitem.wpn9 = 0;
8187 168 tempitem.wpn10 = 0;
8188 168 break;
8189 }
8190 case itype_raft:
8191 {
8192 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8193 84 tempitem.misc1 = 0;
8194 84 tempitem.misc2 = 0;
8195 84 tempitem.misc3 = 0;
8196 84 tempitem.misc4 = 0;
8197 84 tempitem.misc5 = 0;
8198 84 tempitem.misc6 = 0;
8199 84 tempitem.misc7 = 0;
8200 84 tempitem.misc8 = 0;
8201 84 tempitem.misc9 = 0;
8202 84 tempitem.misc10 = 0;
8203 84 tempitem.wpn = 0;
8204 84 tempitem.wpn2 = 0;
8205 84 tempitem.wpn3 = 0;
8206 84 tempitem.wpn4 = 0;
8207 84 tempitem.wpn5 = 0;
8208 84 tempitem.wpn6 = 0;
8209 84 tempitem.wpn7 = 0;
8210 84 tempitem.wpn8 = 0;
8211 84 tempitem.wpn9 = 0;
8212 84 tempitem.wpn10 = 0;
8213 84 break;
8214 }
8215 case itype_ladder:
8216 {
8217 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8218 168 tempitem.misc1 = 0;
8219 168 tempitem.misc2 = 0;
8220 168 tempitem.misc3 = 0;
8221 168 tempitem.misc4 = 0;
8222 168 tempitem.misc5 = 0;
8223 168 tempitem.misc6 = 0;
8224 168 tempitem.misc7 = 0;
8225 168 tempitem.misc8 = 0;
8226 168 tempitem.misc9 = 0;
8227 168 tempitem.misc10 = 0;
8228 168 tempitem.wpn = 0;
8229 168 tempitem.wpn2 = 0;
8230 168 tempitem.wpn3 = 0;
8231 168 tempitem.wpn4 = 0;
8232 168 tempitem.wpn5 = 0;
8233 168 tempitem.wpn6 = 0;
8234 168 tempitem.wpn7 = 0;
8235 168 tempitem.wpn8 = 0;
8236 168 tempitem.wpn9 = 0;
8237 168 tempitem.wpn10 = 0;
8238 168 break;
8239 }
8240 case itype_book:
8241 {
8242 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8243 99 tempitem.misc1 = 0;
8244 99 tempitem.misc2 = 0;
8245 99 tempitem.misc3 = 0;
8246 99 tempitem.misc4 = 0;
8247 99 tempitem.misc5 = 0;
8248 99 tempitem.misc6 = 0;
8249 99 tempitem.misc7 = 0;
8250 99 tempitem.misc8 = 0;
8251 99 tempitem.misc9 = 0;
8252 99 tempitem.misc10 = 0;
8253 99 tempitem.wpn3 = 0;
8254 99 tempitem.wpn4 = 0;
8255 99 tempitem.wpn5 = 0;
8256 99 tempitem.wpn6 = 0;
8257 99 tempitem.wpn7 = 0;
8258 99 tempitem.wpn8 = 0;
8259 99 tempitem.wpn9 = 0;
8260 99 tempitem.wpn10 = 0;
8261 99 break;
8262 }
8263 case itype_magickey:
8264 {
8265 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8266 84 tempitem.misc1 = 0;
8267 84 tempitem.misc2 = 0;
8268 84 tempitem.misc3 = 0;
8269 84 tempitem.misc4 = 0;
8270 84 tempitem.misc5 = 0;
8271 84 tempitem.misc6 = 0;
8272 84 tempitem.misc7 = 0;
8273 84 tempitem.misc8 = 0;
8274 84 tempitem.misc9 = 0;
8275 84 tempitem.misc10 = 0;
8276 84 tempitem.wpn = 0;
8277 84 tempitem.wpn2 = 0;
8278 84 tempitem.wpn3 = 0;
8279 84 tempitem.wpn4 = 0;
8280 84 tempitem.wpn5 = 0;
8281 84 tempitem.wpn6 = 0;
8282 84 tempitem.wpn7 = 0;
8283 84 tempitem.wpn8 = 0;
8284 84 tempitem.wpn9 = 0;
8285 84 tempitem.wpn10 = 0;
8286 84 break;
8287 }
8288 case itype_bracelet:
8289 {
8290 255 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8291 255 tempitem.misc1 = 0;
8292 255 tempitem.misc2 = 0;
8293 255 tempitem.misc3 = 0;
8294 255 tempitem.misc4 = 0;
8295 255 tempitem.misc5 = 0;
8296 255 tempitem.misc6 = 0;
8297 255 tempitem.misc7 = 0;
8298 255 tempitem.misc8 = 0;
8299 255 tempitem.misc9 = 0;
8300 255 tempitem.misc10 = 0;
8301 255 tempitem.wpn = 0;
8302 255 tempitem.wpn2 = 0;
8303 255 tempitem.wpn3 = 0;
8304 255 tempitem.wpn4 = 0;
8305 255 tempitem.wpn5 = 0;
8306 255 tempitem.wpn6 = 0;
8307 255 tempitem.wpn7 = 0;
8308 255 tempitem.wpn8 = 0;
8309 255 tempitem.wpn9 = 0;
8310 255 tempitem.wpn10 = 0;
8311 255 break;
8312 }
8313 case itype_flippers:
8314 {
8315 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8316 85 tempitem.misc1 = 0;
8317 85 tempitem.misc2 = 0;
8318 85 tempitem.misc3 = 0;
8319 85 tempitem.misc4 = 0;
8320 85 tempitem.misc5 = 0;
8321 85 tempitem.misc6 = 0;
8322 85 tempitem.misc7 = 0;
8323 85 tempitem.misc8 = 0;
8324 85 tempitem.misc9 = 0;
8325 85 tempitem.misc10 = 0;
8326 85 tempitem.wpn = 0;
8327 85 tempitem.wpn2 = 0;
8328 85 tempitem.wpn3 = 0;
8329 85 tempitem.wpn4 = 0;
8330 85 tempitem.wpn5 = 0;
8331 85 tempitem.wpn6 = 0;
8332 85 tempitem.wpn7 = 0;
8333 85 tempitem.wpn8 = 0;
8334 85 tempitem.wpn9 = 0;
8335 85 tempitem.wpn10 = 0;
8336 85 break;
8337 }
8338 case itype_boots:
8339 {
8340 86 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8341 86 tempitem.misc1 = 0;
8342 86 tempitem.misc2 = 0;
8343 86 tempitem.misc3 = 0;
8344 86 tempitem.misc4 = 0;
8345 86 tempitem.misc5 = 0;
8346 86 tempitem.misc6 = 0;
8347 86 tempitem.misc7 = 0;
8348 86 tempitem.misc8 = 0;
8349 86 tempitem.misc9 = 0;
8350 86 tempitem.misc10 = 0;
8351 86 tempitem.wpn = 0;
8352 86 tempitem.wpn2 = 0;
8353 86 tempitem.wpn3 = 0;
8354 86 tempitem.wpn4 = 0;
8355 86 tempitem.wpn5 = 0;
8356 86 tempitem.wpn6 = 0;
8357 86 tempitem.wpn7 = 0;
8358 86 tempitem.wpn8 = 0;
8359 86 tempitem.wpn9 = 0;
8360 86 tempitem.wpn10 = 0;
8361 86 break;
8362 }
8363 case itype_hookshot:
8364 {
8365 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8366 168 tempitem.misc5 = 0;
8367 168 tempitem.misc6 = 0;
8368 168 tempitem.misc7 = 0;
8369 168 tempitem.misc8 = 0;
8370 168 tempitem.misc9 = 0;
8371 168 tempitem.misc10 = 0;
8372 168 tempitem.wpn5 = 0;
8373 168 tempitem.wpn6 = 0;
8374 168 tempitem.wpn7 = 0;
8375 168 tempitem.wpn8 = 0;
8376 168 tempitem.wpn9 = 0;
8377 168 tempitem.wpn10 = 0;
8378 168 break;
8379 }
8380 case itype_lens:
8381 {
8382 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8383 84 tempitem.misc2 = 0;
8384 84 tempitem.misc3 = 0;
8385 84 tempitem.misc4 = 0;
8386 84 tempitem.misc5 = 0;
8387 84 tempitem.misc6 = 0;
8388 84 tempitem.misc7 = 0;
8389 84 tempitem.misc8 = 0;
8390 84 tempitem.misc9 = 0;
8391 84 tempitem.misc10 = 0;
8392 84 tempitem.wpn = 0;
8393 84 tempitem.wpn2 = 0;
8394 84 tempitem.wpn3 = 0;
8395 84 tempitem.wpn4 = 0;
8396 84 tempitem.wpn5 = 0;
8397 84 tempitem.wpn6 = 0;
8398 84 tempitem.wpn7 = 0;
8399 84 tempitem.wpn8 = 0;
8400 84 tempitem.wpn9 = 0;
8401 84 tempitem.wpn10 = 0;
8402 84 break;
8403 }
8404 case itype_hammer:
8405 {
8406 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8407 85 tempitem.misc1 = 0;
8408 85 tempitem.misc2 = 0;
8409 85 tempitem.misc3 = 0;
8410 85 tempitem.misc4 = 0;
8411 85 tempitem.misc5 = 0;
8412 85 tempitem.misc6 = 0;
8413 85 tempitem.misc7 = 0;
8414 85 tempitem.misc8 = 0;
8415 85 tempitem.misc9 = 0;
8416 85 tempitem.misc10 = 0;
8417 85 tempitem.wpn3 = 0;
8418 85 tempitem.wpn4 = 0;
8419 85 tempitem.wpn5 = 0;
8420 85 tempitem.wpn6 = 0;
8421 85 tempitem.wpn7 = 0;
8422 85 tempitem.wpn8 = 0;
8423 85 tempitem.wpn9 = 0;
8424 85 tempitem.wpn10 = 0;
8425 85 break;
8426 }
8427 case itype_divinefire:
8428 {
8429 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8430 84 tempitem.misc3 = 0;
8431 84 tempitem.misc4 = 0;
8432 84 tempitem.misc5 = 0;
8433 84 tempitem.misc6 = 0;
8434 84 tempitem.misc7 = 0;
8435 84 tempitem.misc8 = 0;
8436 84 tempitem.misc9 = 0;
8437 84 tempitem.misc10 = 0;
8438 84 tempitem.wpn6 = 0;
8439 84 tempitem.wpn7 = 0;
8440 84 tempitem.wpn8 = 0;
8441 84 tempitem.wpn9 = 0;
8442 84 tempitem.wpn10 = 0;
8443 84 break;
8444 }
8445 case itype_divineescape:
8446 {
8447 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8448 84 tempitem.misc2 = 0;
8449 84 tempitem.misc3 = 0;
8450 84 tempitem.misc4 = 0;
8451 84 tempitem.misc5 = 0;
8452 84 tempitem.misc6 = 0;
8453 84 tempitem.misc7 = 0;
8454 84 tempitem.misc8 = 0;
8455 84 tempitem.misc9 = 0;
8456 84 tempitem.misc10 = 0;
8457 84 tempitem.wpn = 0;
8458 84 tempitem.wpn2 = 0;
8459 84 tempitem.wpn3 = 0;
8460 84 tempitem.wpn4 = 0;
8461 84 tempitem.wpn5 = 0;
8462 84 tempitem.wpn6 = 0;
8463 84 tempitem.wpn7 = 0;
8464 84 tempitem.wpn8 = 0;
8465 84 tempitem.wpn9 = 0;
8466 84 tempitem.wpn10 = 0;
8467 84 break;
8468 }
8469 case itype_divineprotection:
8470 {
8471 84 tempitem.flags &= ~ (ITEM_FLAG5);
8472 84 tempitem.misc2 = 0;
8473 84 tempitem.misc3 = 0;
8474 84 tempitem.misc4 = 0;
8475 84 tempitem.misc5 = 0;
8476 84 tempitem.misc6 = 0;
8477 84 tempitem.misc7 = 0;
8478 84 tempitem.misc8 = 0;
8479 84 tempitem.misc9 = 0;
8480 84 tempitem.misc10 = 0;
8481 84 break;
8482 }
8483 case itype_bomb:
8484 {
8485 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8486 99 tempitem.misc4 = 0;
8487 99 tempitem.misc5 = 0;
8488 99 tempitem.misc6 = 0;
8489 99 tempitem.misc7 = 0;
8490 99 tempitem.misc8 = 0;
8491 99 tempitem.misc9 = 0;
8492 99 tempitem.misc10 = 0;
8493 99 tempitem.wpn3 = 0;
8494 99 tempitem.wpn4 = 0;
8495 99 tempitem.wpn5 = 0;
8496 99 tempitem.wpn6 = 0;
8497 99 tempitem.wpn7 = 0;
8498 99 tempitem.wpn8 = 0;
8499 99 tempitem.wpn9 = 0;
8500 99 tempitem.wpn10 = 0;
8501 99 break;
8502 }
8503 case itype_sbomb:
8504 {
8505 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8506 84 tempitem.misc4 = 0;
8507 84 tempitem.misc5 = 0;
8508 84 tempitem.misc6 = 0;
8509 84 tempitem.misc7 = 0;
8510 84 tempitem.misc8 = 0;
8511 84 tempitem.misc9 = 0;
8512 84 tempitem.misc10 = 0;
8513 84 tempitem.wpn3 = 0;
8514 84 tempitem.wpn4 = 0;
8515 84 tempitem.wpn5 = 0;
8516 84 tempitem.wpn6 = 0;
8517 84 tempitem.wpn7 = 0;
8518 84 tempitem.wpn8 = 0;
8519 84 tempitem.wpn9 = 0;
8520 84 tempitem.wpn10 = 0;
8521 84 break;
8522 }
8523 case itype_clock:
8524 {
8525 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8526 85 tempitem.misc2 = 0;
8527 85 tempitem.misc3 = 0;
8528 85 tempitem.misc4 = 0;
8529 85 tempitem.misc5 = 0;
8530 85 tempitem.misc6 = 0;
8531 85 tempitem.misc7 = 0;
8532 85 tempitem.misc8 = 0;
8533 85 tempitem.misc9 = 0;
8534 85 tempitem.misc10 = 0;
8535 85 tempitem.wpn = 0;
8536 85 tempitem.wpn2 = 0;
8537 85 tempitem.wpn3 = 0;
8538 85 tempitem.wpn4 = 0;
8539 85 tempitem.wpn5 = 0;
8540 85 tempitem.wpn6 = 0;
8541 85 tempitem.wpn7 = 0;
8542 85 tempitem.wpn8 = 0;
8543 85 tempitem.wpn9 = 0;
8544 85 tempitem.wpn10 = 0;
8545 85 break;
8546 }
8547 case itype_key:
8548 {
8549 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8550 84 tempitem.misc1 = 0;
8551 84 tempitem.misc2 = 0;
8552 84 tempitem.misc3 = 0;
8553 84 tempitem.misc4 = 0;
8554 84 tempitem.misc5 = 0;
8555 84 tempitem.misc6 = 0;
8556 84 tempitem.misc7 = 0;
8557 84 tempitem.misc8 = 0;
8558 84 tempitem.misc9 = 0;
8559 84 tempitem.misc10 = 0;
8560 84 tempitem.wpn = 0;
8561 84 tempitem.wpn2 = 0;
8562 84 tempitem.wpn3 = 0;
8563 84 tempitem.wpn4 = 0;
8564 84 tempitem.wpn5 = 0;
8565 84 tempitem.wpn6 = 0;
8566 84 tempitem.wpn7 = 0;
8567 84 tempitem.wpn8 = 0;
8568 84 tempitem.wpn9 = 0;
8569 84 tempitem.wpn10 = 0;
8570 84 break;
8571 }
8572 case itype_magiccontainer:
8573 {
8574 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8575 85 tempitem.misc1 = 0;
8576 85 tempitem.misc2 = 0;
8577 85 tempitem.misc3 = 0;
8578 85 tempitem.misc4 = 0;
8579 85 tempitem.misc5 = 0;
8580 85 tempitem.misc6 = 0;
8581 85 tempitem.misc7 = 0;
8582 85 tempitem.misc8 = 0;
8583 85 tempitem.misc9 = 0;
8584 85 tempitem.misc10 = 0;
8585 85 tempitem.wpn = 0;
8586 85 tempitem.wpn2 = 0;
8587 85 tempitem.wpn3 = 0;
8588 85 tempitem.wpn4 = 0;
8589 85 tempitem.wpn5 = 0;
8590 85 tempitem.wpn6 = 0;
8591 85 tempitem.wpn7 = 0;
8592 85 tempitem.wpn8 = 0;
8593 85 tempitem.wpn9 = 0;
8594 85 tempitem.wpn10 = 0;
8595 85 break;
8596 }
8597 case itype_triforcepiece:
8598 {
8599 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8600 168 tempitem.misc3 = 0;
8601 168 tempitem.misc4 = 0;
8602 168 tempitem.misc5 = 0;
8603 168 tempitem.misc6 = 0;
8604 168 tempitem.misc7 = 0;
8605 168 tempitem.misc8 = 0;
8606 168 tempitem.misc9 = 0;
8607 168 tempitem.misc10 = 0;
8608 168 tempitem.wpn = 0;
8609 168 tempitem.wpn2 = 0;
8610 168 tempitem.wpn3 = 0;
8611 168 tempitem.wpn4 = 0;
8612 168 tempitem.wpn5 = 0;
8613 168 tempitem.wpn6 = 0;
8614 168 tempitem.wpn7 = 0;
8615 168 tempitem.wpn8 = 0;
8616 168 tempitem.wpn9 = 0;
8617 168 tempitem.wpn10 = 0;
8618 168 break;
8619 }
8620 case itype_map: case itype_compass: case itype_bosskey:
8621 {
8622 253 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8623 253 tempitem.misc1 = 0;
8624 253 tempitem.misc2 = 0;
8625 253 tempitem.misc3 = 0;
8626 253 tempitem.misc4 = 0;
8627 253 tempitem.misc5 = 0;
8628 253 tempitem.misc6 = 0;
8629 253 tempitem.misc7 = 0;
8630 253 tempitem.misc8 = 0;
8631 253 tempitem.misc9 = 0;
8632 253 tempitem.misc10 = 0;
8633 253 tempitem.wpn = 0;
8634 253 tempitem.wpn2 = 0;
8635 253 tempitem.wpn3 = 0;
8636 253 tempitem.wpn4 = 0;
8637 253 tempitem.wpn5 = 0;
8638 253 tempitem.wpn6 = 0;
8639 253 tempitem.wpn7 = 0;
8640 253 tempitem.wpn8 = 0;
8641 253 tempitem.wpn9 = 0;
8642 253 tempitem.wpn10 = 0;
8643 253 break;
8644 }
8645 case itype_quiver:
8646 {
8647 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8648 336 tempitem.misc3 = 0;
8649 336 tempitem.misc4 = 0;
8650 336 tempitem.misc5 = 0;
8651 336 tempitem.misc6 = 0;
8652 336 tempitem.misc7 = 0;
8653 336 tempitem.misc8 = 0;
8654 336 tempitem.misc9 = 0;
8655 336 tempitem.misc10 = 0;
8656 336 tempitem.wpn = 0;
8657 336 tempitem.wpn2 = 0;
8658 336 tempitem.wpn3 = 0;
8659 336 tempitem.wpn4 = 0;
8660 336 tempitem.wpn5 = 0;
8661 336 tempitem.wpn6 = 0;
8662 336 tempitem.wpn7 = 0;
8663 336 tempitem.wpn8 = 0;
8664 336 tempitem.wpn9 = 0;
8665 336 tempitem.wpn10 = 0;
8666 336 break;
8667 }
8668 case itype_lkey:
8669 {
8670 86 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8671 86 tempitem.misc1 = 0;
8672 86 tempitem.misc2 = 0;
8673 86 tempitem.misc3 = 0;
8674 86 tempitem.misc4 = 0;
8675 86 tempitem.misc5 = 0;
8676 86 tempitem.misc6 = 0;
8677 86 tempitem.misc7 = 0;
8678 86 tempitem.misc8 = 0;
8679 86 tempitem.misc9 = 0;
8680 86 tempitem.misc10 = 0;
8681 86 tempitem.wpn = 0;
8682 86 tempitem.wpn2 = 0;
8683 86 tempitem.wpn3 = 0;
8684 86 tempitem.wpn4 = 0;
8685 86 tempitem.wpn5 = 0;
8686 86 tempitem.wpn6 = 0;
8687 86 tempitem.wpn7 = 0;
8688 86 tempitem.wpn8 = 0;
8689 86 tempitem.wpn9 = 0;
8690 86 tempitem.wpn10 = 0;
8691 86 break;
8692 }
8693 case itype_cbyrna:
8694 {
8695 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8696 84 tempitem.misc4 = 0;
8697 84 tempitem.misc5 = 0;
8698 84 tempitem.misc6 = 0;
8699 84 tempitem.misc7 = 0;
8700 84 tempitem.misc8 = 0;
8701 84 tempitem.misc9 = 0;
8702 84 tempitem.misc10 = 0;
8703 84 tempitem.wpn6 = 0;
8704 84 tempitem.wpn7 = 0;
8705 84 tempitem.wpn8 = 0;
8706 84 tempitem.wpn9 = 0;
8707 84 tempitem.wpn10 = 0;
8708 84 break;
8709 }
8710 case itype_rupee: case itype_arrowammo:
8711 {
8712 1047 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8713 1047 tempitem.misc1 = 0;
8714 1047 tempitem.misc2 = 0;
8715 1047 tempitem.misc3 = 0;
8716 1047 tempitem.misc4 = 0;
8717 1047 tempitem.misc5 = 0;
8718 1047 tempitem.misc6 = 0;
8719 1047 tempitem.misc7 = 0;
8720 1047 tempitem.misc8 = 0;
8721 1047 tempitem.misc9 = 0;
8722 1047 tempitem.misc10 = 0;
8723 1047 tempitem.wpn = 0;
8724 1047 tempitem.wpn2 = 0;
8725 1047 tempitem.wpn3 = 0;
8726 1047 tempitem.wpn4 = 0;
8727 1047 tempitem.wpn5 = 0;
8728 1047 tempitem.wpn6 = 0;
8729 1047 tempitem.wpn7 = 0;
8730 1047 tempitem.wpn8 = 0;
8731 1047 tempitem.wpn9 = 0;
8732 1047 tempitem.wpn10 = 0;
8733 1047 break;
8734 }
8735 case itype_fairy:
8736 {
8737 152 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8738 152 tempitem.misc4 = 0;
8739 152 tempitem.misc5 = 0;
8740 152 tempitem.misc6 = 0;
8741 152 tempitem.misc7 = 0;
8742 152 tempitem.misc8 = 0;
8743 152 tempitem.misc9 = 0;
8744 152 tempitem.misc10 = 0;
8745 152 tempitem.wpn = 0;
8746 152 tempitem.wpn2 = 0;
8747 152 tempitem.wpn3 = 0;
8748 152 tempitem.wpn4 = 0;
8749 152 tempitem.wpn5 = 0;
8750 152 tempitem.wpn6 = 0;
8751 152 tempitem.wpn7 = 0;
8752 152 tempitem.wpn8 = 0;
8753 152 tempitem.wpn9 = 0;
8754 152 tempitem.wpn10 = 0;
8755 152 break;
8756 }
8757 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8758 {
8759 903 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8760 903 tempitem.misc1 = 0;
8761 903 tempitem.misc2 = 0;
8762 903 tempitem.misc3 = 0;
8763 903 tempitem.misc4 = 0;
8764 903 tempitem.misc5 = 0;
8765 903 tempitem.misc6 = 0;
8766 903 tempitem.misc7 = 0;
8767 903 tempitem.misc8 = 0;
8768 903 tempitem.misc9 = 0;
8769 903 tempitem.misc10 = 0;
8770 903 tempitem.wpn = 0;
8771 903 tempitem.wpn2 = 0;
8772 903 tempitem.wpn3 = 0;
8773 903 tempitem.wpn4 = 0;
8774 903 tempitem.wpn5 = 0;
8775 903 tempitem.wpn6 = 0;
8776 903 tempitem.wpn7 = 0;
8777 903 tempitem.wpn8 = 0;
8778 903 tempitem.wpn9 = 0;
8779 903 tempitem.wpn10 = 0;
8780 903 break;
8781 }
8782 case itype_bombbag:
8783 {
8784 336 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8785 336 tempitem.misc3 = 0;
8786 336 tempitem.misc4 = 0;
8787 336 tempitem.misc5 = 0;
8788 336 tempitem.misc6 = 0;
8789 336 tempitem.misc7 = 0;
8790 336 tempitem.misc8 = 0;
8791 336 tempitem.misc9 = 0;
8792 336 tempitem.misc10 = 0;
8793 336 tempitem.wpn = 0;
8794 336 tempitem.wpn2 = 0;
8795 336 tempitem.wpn3 = 0;
8796 336 tempitem.wpn4 = 0;
8797 336 tempitem.wpn5 = 0;
8798 336 tempitem.wpn6 = 0;
8799 336 tempitem.wpn7 = 0;
8800 336 tempitem.wpn8 = 0;
8801 336 tempitem.wpn9 = 0;
8802 336 tempitem.wpn10 = 0;
8803 336 break;
8804 }
8805 case itype_rocs:
8806 {
8807 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8808 84 tempitem.misc1 = 0;
8809 84 tempitem.misc2 = 0;
8810 84 tempitem.misc3 = 0;
8811 84 tempitem.misc4 = 0;
8812 84 tempitem.misc5 = 0;
8813 84 tempitem.misc6 = 0;
8814 84 tempitem.misc7 = 0;
8815 84 tempitem.misc8 = 0;
8816 84 tempitem.misc9 = 0;
8817 84 tempitem.misc10 = 0;
8818 84 tempitem.wpn = 0;
8819 84 tempitem.wpn2 = 0;
8820 84 tempitem.wpn3 = 0;
8821 84 tempitem.wpn4 = 0;
8822 84 tempitem.wpn5 = 0;
8823 84 tempitem.wpn6 = 0;
8824 84 tempitem.wpn7 = 0;
8825 84 tempitem.wpn8 = 0;
8826 84 tempitem.wpn9 = 0;
8827 84 tempitem.wpn10 = 0;
8828 84 break;
8829 }
8830 case itype_hoverboots:
8831 {
8832 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8833 84 tempitem.misc2 = 0;
8834 84 tempitem.misc3 = 0;
8835 84 tempitem.misc4 = 0;
8836 84 tempitem.misc5 = 0;
8837 84 tempitem.misc6 = 0;
8838 84 tempitem.misc7 = 0;
8839 84 tempitem.misc8 = 0;
8840 84 tempitem.misc9 = 0;
8841 84 tempitem.misc10 = 0;
8842 84 tempitem.wpn2 = 0;
8843 84 tempitem.wpn3 = 0;
8844 84 tempitem.wpn4 = 0;
8845 84 tempitem.wpn5 = 0;
8846 84 tempitem.wpn6 = 0;
8847 84 tempitem.wpn7 = 0;
8848 84 tempitem.wpn8 = 0;
8849 84 tempitem.wpn9 = 0;
8850 84 tempitem.wpn10 = 0;
8851 84 break;
8852 }
8853 case itype_spinscroll:
8854 {
8855 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8856 84 tempitem.misc2 = 0;
8857 84 tempitem.misc3 = 0;
8858 84 tempitem.misc4 = 0;
8859 84 tempitem.misc5 = 0;
8860 84 tempitem.misc6 = 0;
8861 84 tempitem.misc7 = 0;
8862 84 tempitem.misc8 = 0;
8863 84 tempitem.misc9 = 0;
8864 84 tempitem.misc10 = 0;
8865 84 tempitem.wpn = 0;
8866 84 tempitem.wpn2 = 0;
8867 84 tempitem.wpn3 = 0;
8868 84 tempitem.wpn4 = 0;
8869 84 tempitem.wpn5 = 0;
8870 84 tempitem.wpn6 = 0;
8871 84 tempitem.wpn7 = 0;
8872 84 tempitem.wpn8 = 0;
8873 84 tempitem.wpn9 = 0;
8874 84 tempitem.wpn10 = 0;
8875 84 break;
8876 }
8877 case itype_crossscroll:
8878 {
8879 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8880 84 tempitem.misc1 = 0;
8881 84 tempitem.misc2 = 0;
8882 84 tempitem.misc3 = 0;
8883 84 tempitem.misc4 = 0;
8884 84 tempitem.misc5 = 0;
8885 84 tempitem.misc6 = 0;
8886 84 tempitem.misc7 = 0;
8887 84 tempitem.misc8 = 0;
8888 84 tempitem.misc9 = 0;
8889 84 tempitem.misc10 = 0;
8890 84 tempitem.wpn = 0;
8891 84 tempitem.wpn2 = 0;
8892 84 tempitem.wpn3 = 0;
8893 84 tempitem.wpn4 = 0;
8894 84 tempitem.wpn5 = 0;
8895 84 tempitem.wpn6 = 0;
8896 84 tempitem.wpn7 = 0;
8897 84 tempitem.wpn8 = 0;
8898 84 tempitem.wpn9 = 0;
8899 84 tempitem.wpn10 = 0;
8900 84 break;
8901 }
8902 case itype_quakescroll:
8903 {
8904 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8905 84 tempitem.misc3 = 0;
8906 84 tempitem.misc4 = 0;
8907 84 tempitem.misc5 = 0;
8908 84 tempitem.misc6 = 0;
8909 84 tempitem.misc7 = 0;
8910 84 tempitem.misc8 = 0;
8911 84 tempitem.misc9 = 0;
8912 84 tempitem.misc10 = 0;
8913 84 tempitem.wpn = 0;
8914 84 tempitem.wpn2 = 0;
8915 84 tempitem.wpn3 = 0;
8916 84 tempitem.wpn4 = 0;
8917 84 tempitem.wpn5 = 0;
8918 84 tempitem.wpn6 = 0;
8919 84 tempitem.wpn7 = 0;
8920 84 tempitem.wpn8 = 0;
8921 84 tempitem.wpn9 = 0;
8922 84 tempitem.wpn10 = 0;
8923 84 break;
8924 }
8925 case itype_whispring:
8926 {
8927 169 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8928 169 tempitem.misc2 = 0;
8929 169 tempitem.misc3 = 0;
8930 169 tempitem.misc4 = 0;
8931 169 tempitem.misc5 = 0;
8932 169 tempitem.misc6 = 0;
8933 169 tempitem.misc7 = 0;
8934 169 tempitem.misc8 = 0;
8935 169 tempitem.misc9 = 0;
8936 169 tempitem.misc10 = 0;
8937 169 tempitem.wpn = 0;
8938 169 tempitem.wpn2 = 0;
8939 169 tempitem.wpn3 = 0;
8940 169 tempitem.wpn4 = 0;
8941 169 tempitem.wpn5 = 0;
8942 169 tempitem.wpn6 = 0;
8943 169 tempitem.wpn7 = 0;
8944 169 tempitem.wpn8 = 0;
8945 169 tempitem.wpn9 = 0;
8946 169 tempitem.wpn10 = 0;
8947 169 break;
8948 }
8949 case itype_chargering:
8950 {
8951 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8952 168 tempitem.misc3 = 0;
8953 168 tempitem.misc4 = 0;
8954 168 tempitem.misc5 = 0;
8955 168 tempitem.misc6 = 0;
8956 168 tempitem.misc7 = 0;
8957 168 tempitem.misc8 = 0;
8958 168 tempitem.misc9 = 0;
8959 168 tempitem.misc10 = 0;
8960 168 tempitem.wpn = 0;
8961 168 tempitem.wpn2 = 0;
8962 168 tempitem.wpn3 = 0;
8963 168 tempitem.wpn4 = 0;
8964 168 tempitem.wpn5 = 0;
8965 168 tempitem.wpn6 = 0;
8966 168 tempitem.wpn7 = 0;
8967 168 tempitem.wpn8 = 0;
8968 168 tempitem.wpn9 = 0;
8969 168 tempitem.wpn10 = 0;
8970 168 break;
8971 }
8972 case itype_perilscroll:
8973 {
8974 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8975 84 tempitem.misc2 = 0;
8976 84 tempitem.misc3 = 0;
8977 84 tempitem.misc4 = 0;
8978 84 tempitem.misc5 = 0;
8979 84 tempitem.misc6 = 0;
8980 84 tempitem.misc7 = 0;
8981 84 tempitem.misc8 = 0;
8982 84 tempitem.misc9 = 0;
8983 84 tempitem.misc10 = 0;
8984 84 tempitem.wpn = 0;
8985 84 tempitem.wpn2 = 0;
8986 84 tempitem.wpn3 = 0;
8987 84 tempitem.wpn4 = 0;
8988 84 tempitem.wpn5 = 0;
8989 84 tempitem.wpn6 = 0;
8990 84 tempitem.wpn7 = 0;
8991 84 tempitem.wpn8 = 0;
8992 84 tempitem.wpn9 = 0;
8993 84 tempitem.wpn10 = 0;
8994 84 break;
8995 }
8996 case itype_wealthmedal:
8997 {
8998 253 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8999 253 tempitem.misc2 = 0;
9000 253 tempitem.misc3 = 0;
9001 253 tempitem.misc4 = 0;
9002 253 tempitem.misc5 = 0;
9003 253 tempitem.misc6 = 0;
9004 253 tempitem.misc7 = 0;
9005 253 tempitem.misc8 = 0;
9006 253 tempitem.misc9 = 0;
9007 253 tempitem.misc10 = 0;
9008 253 tempitem.wpn = 0;
9009 253 tempitem.wpn2 = 0;
9010 253 tempitem.wpn3 = 0;
9011 253 tempitem.wpn4 = 0;
9012 253 tempitem.wpn5 = 0;
9013 253 tempitem.wpn6 = 0;
9014 253 tempitem.wpn7 = 0;
9015 253 tempitem.wpn8 = 0;
9016 253 tempitem.wpn9 = 0;
9017 253 tempitem.wpn10 = 0;
9018 253 break;
9019 }
9020 case itype_heartring:
9021 {
9022 254 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9023 254 tempitem.misc3 = 0;
9024 254 tempitem.misc4 = 0;
9025 254 tempitem.misc5 = 0;
9026 254 tempitem.misc6 = 0;
9027 254 tempitem.misc7 = 0;
9028 254 tempitem.misc8 = 0;
9029 254 tempitem.misc9 = 0;
9030 254 tempitem.misc10 = 0;
9031 254 tempitem.wpn = 0;
9032 254 tempitem.wpn2 = 0;
9033 254 tempitem.wpn3 = 0;
9034 254 tempitem.wpn4 = 0;
9035 254 tempitem.wpn5 = 0;
9036 254 tempitem.wpn6 = 0;
9037 254 tempitem.wpn7 = 0;
9038 254 tempitem.wpn8 = 0;
9039 254 tempitem.wpn9 = 0;
9040 254 tempitem.wpn10 = 0;
9041 254 break;
9042 }
9043 case itype_magicring:
9044 {
9045 340 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9046 340 tempitem.misc3 = 0;
9047 340 tempitem.misc4 = 0;
9048 340 tempitem.misc5 = 0;
9049 340 tempitem.misc6 = 0;
9050 340 tempitem.misc7 = 0;
9051 340 tempitem.misc8 = 0;
9052 340 tempitem.misc9 = 0;
9053 340 tempitem.misc10 = 0;
9054 340 tempitem.wpn = 0;
9055 340 tempitem.wpn2 = 0;
9056 340 tempitem.wpn3 = 0;
9057 340 tempitem.wpn4 = 0;
9058 340 tempitem.wpn5 = 0;
9059 340 tempitem.wpn6 = 0;
9060 340 tempitem.wpn7 = 0;
9061 340 tempitem.wpn8 = 0;
9062 340 tempitem.wpn9 = 0;
9063 340 tempitem.wpn10 = 0;
9064 340 break;
9065 }
9066 case itype_spinscroll2:
9067 {
9068 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9069 84 tempitem.misc2 = 0;
9070 84 tempitem.misc3 = 0;
9071 84 tempitem.misc4 = 0;
9072 84 tempitem.misc5 = 0;
9073 84 tempitem.misc6 = 0;
9074 84 tempitem.misc7 = 0;
9075 84 tempitem.misc8 = 0;
9076 84 tempitem.misc9 = 0;
9077 84 tempitem.misc10 = 0;
9078 84 tempitem.wpn = 0;
9079 84 tempitem.wpn2 = 0;
9080 84 tempitem.wpn3 = 0;
9081 84 tempitem.wpn4 = 0;
9082 84 tempitem.wpn5 = 0;
9083 84 tempitem.wpn6 = 0;
9084 84 tempitem.wpn7 = 0;
9085 84 tempitem.wpn8 = 0;
9086 84 tempitem.wpn9 = 0;
9087 84 tempitem.wpn10 = 0;
9088 84 break;
9089 }
9090 case itype_quakescroll2:
9091 {
9092 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9093 84 tempitem.misc3 = 0;
9094 84 tempitem.misc4 = 0;
9095 84 tempitem.misc5 = 0;
9096 84 tempitem.misc6 = 0;
9097 84 tempitem.misc7 = 0;
9098 84 tempitem.misc8 = 0;
9099 84 tempitem.misc9 = 0;
9100 84 tempitem.misc10 = 0;
9101 84 tempitem.wpn = 0;
9102 84 tempitem.wpn2 = 0;
9103 84 tempitem.wpn3 = 0;
9104 84 tempitem.wpn4 = 0;
9105 84 tempitem.wpn5 = 0;
9106 84 tempitem.wpn6 = 0;
9107 84 tempitem.wpn7 = 0;
9108 84 tempitem.wpn8 = 0;
9109 84 tempitem.wpn9 = 0;
9110 84 tempitem.wpn10 = 0;
9111 84 break;
9112 }
9113 case itype_agony:
9114 {
9115 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9116 84 tempitem.misc2 = 0;
9117 84 tempitem.misc3 = 0;
9118 84 tempitem.misc4 = 0;
9119 84 tempitem.misc5 = 0;
9120 84 tempitem.misc6 = 0;
9121 84 tempitem.misc7 = 0;
9122 84 tempitem.misc8 = 0;
9123 84 tempitem.misc9 = 0;
9124 84 tempitem.misc10 = 0;
9125 84 tempitem.wpn = 0;
9126 84 tempitem.wpn2 = 0;
9127 84 tempitem.wpn3 = 0;
9128 84 tempitem.wpn4 = 0;
9129 84 tempitem.wpn5 = 0;
9130 84 tempitem.wpn6 = 0;
9131 84 tempitem.wpn7 = 0;
9132 84 tempitem.wpn8 = 0;
9133 84 tempitem.wpn9 = 0;
9134 84 tempitem.wpn10 = 0;
9135 84 break;
9136 }
9137 case itype_stompboots:
9138 {
9139 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9140 84 tempitem.misc1 = 0;
9141 84 tempitem.misc2 = 0;
9142 84 tempitem.misc3 = 0;
9143 84 tempitem.misc4 = 0;
9144 84 tempitem.misc5 = 0;
9145 84 tempitem.misc6 = 0;
9146 84 tempitem.misc7 = 0;
9147 84 tempitem.misc8 = 0;
9148 84 tempitem.misc9 = 0;
9149 84 tempitem.misc10 = 0;
9150 84 tempitem.wpn = 0;
9151 84 tempitem.wpn2 = 0;
9152 84 tempitem.wpn3 = 0;
9153 84 tempitem.wpn4 = 0;
9154 84 tempitem.wpn5 = 0;
9155 84 tempitem.wpn6 = 0;
9156 84 tempitem.wpn7 = 0;
9157 84 tempitem.wpn8 = 0;
9158 84 tempitem.wpn9 = 0;
9159 84 tempitem.wpn10 = 0;
9160 84 break;
9161 }
9162 case itype_whimsicalring:
9163 {
9164 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9165 84 tempitem.misc2 = 0;
9166 84 tempitem.misc3 = 0;
9167 84 tempitem.misc4 = 0;
9168 84 tempitem.misc5 = 0;
9169 84 tempitem.misc6 = 0;
9170 84 tempitem.misc7 = 0;
9171 84 tempitem.misc8 = 0;
9172 84 tempitem.misc9 = 0;
9173 84 tempitem.misc10 = 0;
9174 84 tempitem.wpn = 0;
9175 84 tempitem.wpn2 = 0;
9176 84 tempitem.wpn3 = 0;
9177 84 tempitem.wpn4 = 0;
9178 84 tempitem.wpn5 = 0;
9179 84 tempitem.wpn6 = 0;
9180 84 tempitem.wpn7 = 0;
9181 84 tempitem.wpn8 = 0;
9182 84 tempitem.wpn9 = 0;
9183 84 tempitem.wpn10 = 0;
9184 84 break;
9185 }
9186 case itype_perilring:
9187 {
9188 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9189 85 tempitem.misc2 = 0;
9190 85 tempitem.misc3 = 0;
9191 85 tempitem.misc4 = 0;
9192 85 tempitem.misc5 = 0;
9193 85 tempitem.misc6 = 0;
9194 85 tempitem.misc7 = 0;
9195 85 tempitem.misc8 = 0;
9196 85 tempitem.misc9 = 0;
9197 85 tempitem.misc10 = 0;
9198 85 tempitem.wpn = 0;
9199 85 tempitem.wpn2 = 0;
9200 85 tempitem.wpn3 = 0;
9201 85 tempitem.wpn4 = 0;
9202 85 tempitem.wpn5 = 0;
9203 85 tempitem.wpn6 = 0;
9204 85 tempitem.wpn7 = 0;
9205 85 tempitem.wpn8 = 0;
9206 85 tempitem.wpn9 = 0;
9207 85 tempitem.wpn10 = 0;
9208 85 break;
9209 }
9210 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9211 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9212 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9213 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9214 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9215 {
9216 2368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9217 2368 tempitem.misc1 = 0;
9218 2368 tempitem.misc2 = 0;
9219 2368 tempitem.misc3 = 0;
9220 2368 tempitem.misc4 = 0;
9221 2368 tempitem.misc5 = 0;
9222 2368 tempitem.misc6 = 0;
9223 2368 tempitem.misc7 = 0;
9224 2368 tempitem.misc8 = 0;
9225 2368 tempitem.misc9 = 0;
9226 2368 tempitem.misc10 = 0;
9227 2368 tempitem.wpn = 0;
9228 2368 tempitem.wpn2 = 0;
9229 2368 tempitem.wpn3 = 0;
9230 2368 tempitem.wpn4 = 0;
9231 2368 tempitem.wpn5 = 0;
9232 2368 tempitem.wpn6 = 0;
9233 2368 tempitem.wpn7 = 0;
9234 2368 tempitem.wpn8 = 0;
9235 2368 tempitem.wpn9 = 0;
9236 2368 tempitem.wpn10 = 0;
9237 2368 break;
9238 }
9239 }
9240 21760 }
9241 //Port quest rules to items
9242
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version <= 31)
9243 {
9244
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_bomb)
9245 {
9246
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 10 times.
99 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9247 89 else tempitem.flags &= ~ ITEM_FLAG2;
9248 99 }
9249
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21577 times.
21661 else if(tempitem.family == itype_sbomb)
9250 {
9251
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 74 times.
84 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9252 74 else tempitem.flags &= ~ ITEM_FLAG2;
9253 84 }
9254
9255
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 21324 times.
21577 else if(tempitem.family == itype_brang)
9256 {
9257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9258 253 else tempitem.flags &= ~ ITEM_FLAG4;
9259 253 }
9260
2/2
✓ Branch 0 taken 21225 times.
✓ Branch 1 taken 99 times.
21324 else if(tempitem.family == itype_wand)
9261 {
9262
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 97 times.
99 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9263 97 else tempitem.flags &= ~ ITEM_FLAG3;
9264 99 }
9265 21760 }
9266
9267 //Port quest rules to items
9268
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version <= 37)
9269 {
9270
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21675 times.
21760 if(tempitem.family == itype_flippers)
9271 {
9272
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9273 85 else tempitem.flags &= ~ ITEM_FLAG1;
9274 85 }
9275
2/2
✓ Branch 0 taken 14827 times.
✓ Branch 1 taken 6848 times.
21675 else if(tempitem.family == itype_sword)
9276 {
9277
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9278 6779 else tempitem.flags &= ~ ITEM_FLAG5;
9279 6848 }
9280
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 14728 times.
14827 else if(tempitem.family == itype_wand)
9281 {
9282
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9283 96 else tempitem.flags &= ~ ITEM_FLAG5;
9284 99 }
9285
4/4
✓ Branch 0 taken 14629 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 14423 times.
14728 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9286 {
9287 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9288
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 72 times.
305 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9289 233 else tempitem.flags &= ~ ITEM_FLAG3;
9290 305 }
9291 21760 }
9292
9293
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 38)
9294 {
9295
4/4
✓ Branch 0 taken 21507 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 21339 times.
21760 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9296 {
9297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9298 421 else tempitem.flags &= ~ITEM_FLAG4;
9299
9300
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 410 times.
421 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9301 410 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9302 421 }
9303
2/2
✓ Branch 0 taken 21089 times.
✓ Branch 1 taken 250 times.
21339 else if(tempitem.family == itype_arrow)
9304 {
9305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9306 250 else tempitem.flags &= ~ITEM_FLAG4;
9307
9308
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 246 times.
250 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9309 246 else tempitem.flags |= ITEM_FLAG2;
9310 250 }
9311 21760 }
9312
9313
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 39)
9314 {
9315
6/6
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 21577 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 21371 times.
21760 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9316 {
9317
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 377 times.
389 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9318 377 else tempitem.flags &= ~ITEM_FLAG5;
9319 389 }
9320
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 21204 times.
21371 else if(tempitem.family == itype_potion)
9321 {
9322
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 157 times.
167 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9323 {
9324 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9325 10 }
9326 else
9327 {
9328 157 tempitem.flags |= ITEM_FLAG3;
9329
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 85 times.
157 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9330 72 else tempitem.flags &= ~ITEM_FLAG4;
9331 }
9332 167 }
9333
2/2
✓ Branch 0 taken 21036 times.
✓ Branch 1 taken 168 times.
21204 else if(tempitem.family == itype_triforcepiece)
9334 {
9335
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 152 times.
168 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9336 {
9337 16 tempitem.flags |= ITEM_FLAG3;
9338
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9339 10 else tempitem.flags &= ~ITEM_FLAG4;
9340 16 }
9341 else
9342 {
9343 152 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9344 }
9345 168 }
9346 21760 }
9347
9348
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 40)
9349 {
9350
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 21397 times.
21760 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9351 {
9352
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 316 times.
363 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9353 316 else tempitem.flags &= ~ITEM_FLAG1;
9354 363 }
9355
8/8
✓ Branch 0 taken 21191 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 14343 times.
✓ Branch 3 taken 6848 times.
✓ Branch 4 taken 14244 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 84 times.
✓ Branch 7 taken 14160 times.
21397 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9356 {
9357
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7156 times.
7237 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9358 7156 else tempitem.flags &= ~ITEM_FLAG8;
9359 7237 }
9360
6/6
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
✓ Branch 2 taken 14813 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 85 times.
✓ Branch 5 taken 14728 times.
21760 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9361 {
9362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7032 times.
7032 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9363 7032 else tempitem.flags &= ~ITEM_FLAG7;
9364 7032 }
9365
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 84 times.
14728 else if(tempitem.family == itype_cbyrna)
9366 {
9367 84 tempitem.flags |= ITEM_FLAG7;
9368 84 }
9369 21760 }
9370
9371
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 41 )
9372 {
9373
2/2
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
21760 if(tempitem.family == itype_sword)
9374 {
9375
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9376 6779 else tempitem.flags &= ~ITEM_FLAG9;
9377
9378
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9379 6779 else tempitem.flags &= ~ITEM_FLAG10;
9380 6848 }
9381 21760 }
9382
9383
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 42 )
9384 {
9385
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_wand)
9386 {
9387
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2 times.
99 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9388 97 else tempitem.flags &= ~ITEM_FLAG3;
9389
9390 99 tempitem.flags &= ~ITEM_FLAG6;
9391 99 }
9392
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21576 times.
21661 else if(tempitem.family == itype_hammer)
9393 {
9394 85 tempitem.flags &= ~ITEM_FLAG3;
9395 85 }
9396
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21492 times.
21576 else if(tempitem.family == itype_cbyrna)
9397 {
9398 84 tempitem.flags |= ITEM_FLAG3;
9399
9400 84 tempitem.flags &= ~ITEM_FLAG6;
9401 84 }
9402
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 6848 times.
21492 else if(tempitem.family == itype_sword)
9403 {
9404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6848 times.
6848 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9405 6848 else tempitem.flags &= ~ITEM_FLAG6;
9406 6848 }
9407 21760 }
9408
9409
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 43 )
9410 {
9411
2/2
✓ Branch 0 taken 21630 times.
✓ Branch 1 taken 130 times.
21760 if(tempitem.family == itype_whistle)
9412 {
9413
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9414 127 else tempitem.flags &= ~ITEM_FLAG3;
9415 130 }
9416 21760 }
9417
9418
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 45 )
9419 {
9420
2/2
✓ Branch 0 taken 21675 times.
✓ Branch 1 taken 85 times.
21760 if(tempitem.family == itype_flippers)
9421 {
9422 85 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9423 85 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9424 85 }
9425 21760 }
9426
9427
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 46 )
9428 {
9429
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if(tempitem.family == itype_raft)
9430 {
9431 84 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9432 84 }
9433 21760 }
9434
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if ( s_version < 34 ) //! set the default counter for older quests.
9435 {
9436
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 21686 times.
21760 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9437 {
9438 74 tempitem.cost_counter[0] = 1;
9439 74 }
9440 else
9441 {
9442
2/2
✓ Branch 0 taken 18870 times.
✓ Branch 1 taken 2816 times.
21686 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9443 2816 tempitem.cost_counter[0] = 4;
9444 else
9445 {
9446 18870 tempitem.cost_amount[0] = 0;
9447 18870 tempitem.cost_counter[0] = -1;
9448 }
9449 }
9450 21760 }
9451
9452
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if ( s_version < 35 ) //new Lens of Truth flags
9453 {
9454
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if ( tempitem.family == itype_lens )
9455 {
9456
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 3 times.
84 if ( get_bit(quest_rules,qr_RAFTLENS) )
9457 {
9458 3 tempitem.flags |= ITEM_FLAG4;
9459 3 }
9460
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 45 times.
84 if ( get_bit(quest_rules,qr_LENSHINTS) )
9461 {
9462 45 tempitem.flags |= ITEM_FLAG1;
9463 45 }
9464
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4 times.
84 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9465 {
9466 4 tempitem.flags |= ITEM_FLAG5;
9467 4 }
9468 84 }
9469 21760 }
9470
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9471 {
9472
2/2
✓ Branch 0 taken 174080 times.
✓ Branch 1 taken 21760 times.
195840 for ( int32_t q = 0; q < 8; q++ )
9473 {
9474 174080 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9475 174080 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9476 174080 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9477 174080 tempitem.sprite_initiald[q] = 0;
9478 174080 }
9479
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 21760 times.
65280 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9480 21760 tempitem.sprite_script = 0;
9481 21760 }
9482
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9483 {
9484 21760 tempitem.pickupflag = 0;
9485 21760 }
9486
9487
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 51 )
9488 {
9489
2/2
✓ Branch 0 taken 21554 times.
✓ Branch 1 taken 206 times.
21760 if( tempitem.family == itype_candle )
9490 {
9491 206 tempitem.misc4 = 50; //Step speed
9492 206 }
9493 21760 }
9494
9495
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if( s_version < 52 )
9496 {
9497
2/2
✓ Branch 0 taken 21501 times.
✓ Branch 1 taken 259 times.
21760 if( tempitem.family == itype_shield )
9498 259 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9499 21760 }
9500
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 21760 times.
29440 if(s_version < 53)
9501 {
9502
4/4
✓ Branch 0 taken 21327 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 84 times.
21760 switch(tempitem.family)
9503 {
9504 case itype_arrow:
9505 250 tempitem.cost_counter[1] = crARROWS;
9506 250 tempitem.cost_amount[1] = 1;
9507 250 break;
9508 case itype_bomb:
9509 99 tempitem.cost_counter[1] = crBOMBS;
9510 99 tempitem.cost_amount[1] = 1;
9511 99 break;
9512 case itype_sbomb:
9513 84 tempitem.cost_counter[1] = crSBOMBS;
9514 84 tempitem.cost_amount[1] = 1;
9515 84 break;
9516 default:
9517 21327 tempitem.cost_counter[1] = crNONE;
9518 21327 tempitem.cost_amount[1] = 0;
9519 21327 }
9520 21760 tempitem.magiccosttimer[1] = 0;
9521 21760 }
9522
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 23040 times.
29440 if( s_version < 54 )
9523 {
9524
2/2
✓ Branch 0 taken 22949 times.
✓ Branch 1 taken 91 times.
23040 if( tempitem.family == itype_flippers )
9525 91 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9526 23040 }
9527
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 23040 times.
29440 if(s_version < 55)
9528 {
9529
3/3
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 22684 times.
23040 switch(tempitem.family)
9530 {
9531 case itype_spinscroll:
9532 case itype_quakescroll:
9533 178 tempitem.usesound2 = WAV_ZN1CHARGE;
9534 178 break;
9535 case itype_spinscroll2:
9536 case itype_quakescroll2:
9537 178 tempitem.usesound2 = WAV_ZN1CHARGE2;
9538 178 break;
9539 }
9540 23040 }
9541
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 23040 times.
29440 if(s_version < 56)
9542 {
9543
4/4
✓ Branch 0 taken 22629 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 104 times.
23040 switch(tempitem.family)
9544 {
9545 case itype_divinefire:
9546
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 5 times.
89 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9547
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 80 times.
89 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9548 89 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9549 89 break;
9550 case itype_candle:
9551
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 112 times.
218 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9552 218 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9553 218 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9554 218 break;
9555 case itype_book:
9556 104 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9557 104 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9558 104 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9559 104 break;
9560 }
9561 23040 }
9562
9563
2/2
✓ Branch 0 taken 28234 times.
✓ Branch 1 taken 1206 times.
29440 if(tempitem.fam_type==0) // Always do this
9564 1206 tempitem.fam_type=1;
9565
9566 29440 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9567 29440 }
9568 115 }
9569
9570 115 return 0;
9571 115 }
9572
9573 static bool did_init_def_items = false;
9574 59639 void init_def_items()
9575 {
9576
2/2
✓ Branch 0 taken 59600 times.
✓ Branch 1 taken 39 times.
59639 if(did_init_def_items) return;
9577 39 did_init_def_items = true;
9578 39 default_items[3].cost_counter[1] = crBOMBS;
9579 39 default_items[13].cost_counter[1] = crARROWS;
9580 39 default_items[14].cost_counter[1] = crARROWS;
9581 39 default_items[48].cost_counter[1] = crSBOMBS;
9582 39 default_items[57].cost_counter[1] = crARROWS;
9583 59639 }
9584 59639 void reset_itembuf(itemdata *item, int32_t id)
9585 {
9586 59639 init_def_items();
9587
2/2
✓ Branch 0 taken 25877 times.
✓ Branch 1 taken 33762 times.
59639 if(id<iLast)
9588 {
9589 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9590 33762 word tile = item->tile;
9591 33762 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9592 33762 int32_t ltm = item->ltm;
9593
9594 33762 memcpy(item,&default_items[id],sizeof(itemdata));
9595 33762 item->tile = tile;
9596 33762 item->misc_flags = miscs;
9597 33762 item->csets = cset;
9598 33762 item->frames = frames;
9599 33762 item->speed = speed;
9600 33762 item->delay = delay;
9601 33762 item->ltm = ltm;
9602 33762 }
9603 59639 }
9604
9605 12288 void reset_itemname(int32_t id)
9606 {
9607 12288 sprintf(item_string[id],"zz%03d",id);
9608
9609
2/2
✓ Branch 0 taken 5424 times.
✓ Branch 1 taken 6864 times.
12288 if(id < iLast)
9610 6864 strcpy(item_string[id],old_item_string[id]);
9611 12288 }
9612
9613 115 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9614 {
9615 115 word weapons_to_read=MAXWPNS;
9616 int32_t dummy;
9617 byte padding;
9618 wpndata tempweapon;
9619 115 word s_version=0, s_cversion=0;
9620
9621
9622
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(Header->zelda_version < 0x186)
9623 {
9624 weapons_to_read=64;
9625 }
9626
9627
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(Header->zelda_version < 0x185)
9628 {
9629 weapons_to_read=32;
9630 }
9631
9632
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
9633 {
9634 111 weapons_to_read=0;
9635
9636 //section version info
9637
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
9638 {
9639 return qe_invalid;
9640 }
9641
9642 111 FFCore.quest_format[vWeaponSprites] = s_version;
9643
9644 //al_trace("Weapons version %d\n", s_version);
9645
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_cversion,f,true))
9646 {
9647 return qe_invalid;
9648 }
9649
9650 //section size
9651
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
9652 {
9653 return qe_invalid;
9654 }
9655
9656 //finally... section data
9657
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&weapons_to_read,f,true))
9658 {
9659 return qe_invalid;
9660 }
9661
9662
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 if (!(weapons_to_read >= 0 && weapons_to_read <= WPNCNT))
9663 {
9664 return qe_invalid;
9665 }
9666 111 }
9667
9668
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version>2)
9669 {
9670
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i=0; i<weapons_to_read; i++)
9671 {
9672 char tempname[64];
9673
9674
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(!pfread(tempname, 64, f, keepdata))
9675 {
9676 return qe_invalid;
9677 }
9678
9679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27136 times.
27136 if(keepdata)
9680 {
9681 27136 weapon_string[i][0] = '\0';
9682 27136 strncat(weapon_string[i], tempname, 64 - 1);
9683 27136 }
9684 27136 }
9685
9686
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(s_version<4)
9687 {
9688 if(keepdata)
9689 {
9690 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9691 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9692 }
9693 }
9694
9695
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(s_version<5)
9696 {
9697 if(keepdata)
9698 {
9699 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9700 }
9701 }
9702
9703 /*
9704 if (s_version<6)
9705 {
9706 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9707 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9708 }
9709 */
9710 106 }
9711 else
9712 {
9713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9714
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9715 2313 reset_weaponname(i);
9716 }
9717
9718
2/2
✓ Branch 0 taken 28500 times.
✓ Branch 1 taken 115 times.
28615 for(int32_t i=0; i<weapons_to_read; i++)
9719 {
9720 28500 word oldtile = 0;
9721
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 21332 times.
28500 if (s_version < 8)
9722 {
9723
1/2
✓ Branch 0 taken 21332 times.
✗ Branch 1 not taken.
21332 if (!p_igetw(&oldtile, f, true))
9724 return qe_invalid;
9725 21332 }
9726
9727
1/2
✓ Branch 0 taken 28500 times.
✗ Branch 1 not taken.
28500 if(!p_getc(&tempweapon.misc,f,true))
9728 {
9729 return qe_invalid;
9730 }
9731
9732
1/2
✓ Branch 0 taken 28500 times.
✗ Branch 1 not taken.
28500 if(!p_getc(&tempweapon.csets,f,true))
9733 {
9734 return qe_invalid;
9735 }
9736
9737
1/2
✓ Branch 0 taken 28500 times.
✗ Branch 1 not taken.
28500 if(!p_getc(&tempweapon.frames,f,true))
9738 {
9739 return qe_invalid;
9740 }
9741
9742
1/2
✓ Branch 0 taken 28500 times.
✗ Branch 1 not taken.
28500 if(!p_getc(&tempweapon.speed,f,true))
9743 {
9744 return qe_invalid;
9745 }
9746
9747
1/2
✓ Branch 0 taken 28500 times.
✗ Branch 1 not taken.
28500 if(!p_getc(&tempweapon.type,f,true))
9748 {
9749 return qe_invalid;
9750 }
9751
9752
2/2
✓ Branch 0 taken 20820 times.
✓ Branch 1 taken 7680 times.
28500 if ( s_version >= 7 )
9753 {
9754
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetw(&tempweapon.script,f,true))
9755 {
9756 return qe_invalid;
9757 }
9758
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(!p_igetl(&tempweapon.tile,f,true))
9759 {
9760 return qe_invalid;
9761 }
9762 7680 }
9763
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 20820 times.
28500 if ( s_version < 7 )
9764 {
9765 20820 tempweapon.tile = oldtile;
9766 20820 }
9767
9768
2/2
✓ Branch 0 taken 27476 times.
✓ Branch 1 taken 1024 times.
28500 if(Header->zelda_version < 0x193)
9769 {
9770
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9771 {
9772 return qe_invalid;
9773 }
9774 1024 }
9775
9776
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 1364 times.
28500 if(s_version < 6)
9777 {
9778
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9779 {
9780 4 tempweapon.misc |= WF_BEHIND;
9781 4 }
9782 else
9783 1360 tempweapon.misc &= ~WF_BEHIND;
9784 1364 }
9785
9786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28500 times.
28500 if(keepdata==true)
9787 {
9788 28500 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9789 28500 }
9790 28500 }
9791
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
9793 {
9794
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<2)
9795 {
9796 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9797 9 }
9798
9799
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version<5)
9800 {
9801 9 wpnsbuf[iwQuarterHearts].tile=1;
9802 9 wpnsbuf[iwQuarterHearts].csets=1;
9803 9 }
9804
9805
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(Header->zelda_version < 0x176)
9806 {
9807 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9808 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9809 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9810 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9811 }
9812
9813
2/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115 if((Header->zelda_version < 0x192)||
9814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9815 {
9816 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9817 4 }
9818
9819
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if((Header->zelda_version < 0x210))
9820 {
9821 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9822 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9823 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9824 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9825 4 }
9826 115 }
9827
9828 115 return 0;
9829 115 }
9830
9831 115 void init_guys(int32_t guyversion)
9832 {
9833
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<MAXGUYS; i++)
9834 {
9835 58880 guysbuf[i] = default_guys[0];
9836 58880 }
9837
9838
2/2
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 115 times.
20470 for(int32_t i=0; i<OLDMAXGUYS; i++)
9839 {
9840 20355 guysbuf[i] = default_guys[i];
9841
2/2
✓ Branch 0 taken 20125 times.
✓ Branch 1 taken 230 times.
20355 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9842 20355 guysbuf[i].spr_death = iwDeath;
9843 20355 guysbuf[i].spr_spawn = iwSpawn;
9844 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9845
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 18762 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
20355 if(guyversion<=3 && i==ePATRABS)
9846 {
9847 9 guysbuf[i].bosspal=spDIG;
9848 9 guysbuf[i].cset=14;
9849 9 guysbuf[i].misc9=14;
9850 9 }
9851
9852
2/2
✓ Branch 0 taken 18762 times.
✓ Branch 1 taken 1593 times.
20355 if(guyversion<=3)
9853 {
9854 // Rope/Ghini Flash rules
9855
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9856 {
9857
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9858 {
9859 5 guysbuf[i].flags2 &= ~guy_flashing;
9860 5 }
9861 885 }
9862
9863
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9864 {
9865
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9866 {
9867 18 guysbuf[i].flags2 &= ~guy_flashing;
9868 18 }
9869 531 }
9870
9871
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9872 {
9873
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9874 {
9875 3 guysbuf[i].flags2 |= guy_blinking;
9876 3 }
9877
9878
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9879 {
9880 guysbuf[i].flags2 |= guy_transparent;
9881 }
9882 9 }
9883 1593 }
9884
9885 // Darknut fix
9886
10/10
✓ Branch 0 taken 20240 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 20125 times.
✓ Branch 3 taken 115 times.
✓ Branch 4 taken 20010 times.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 19895 times.
✓ Branch 7 taken 115 times.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 19780 times.
20355 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9887 {
9888
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 205 times.
575 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9889 {
9890 370 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9891 370 guysbuf[i].s_width=guysbuf[i].e_width;
9892 370 guysbuf[i].s_height=guysbuf[i].e_height;
9893 370 }
9894 205 else guysbuf[i].s_tile=860;
9895
9896
2/2
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 45 times.
575 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9897 {
9898 45 guysbuf[i].flags |= guy_bkshield;
9899 45 }
9900 575 }
9901
9902
4/4
✓ Branch 0 taken 20240 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 20347 times.
✓ Branch 3 taken 8 times.
20355 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9903 {
9904 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9905 8 }
9906 20355 }
9907 115 }
9908
9909 2304 void reset_weaponname(int32_t i)
9910 {
9911
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9912 {
9913 792 strcpy(weapon_string[i],old_weapon_string[i]);
9914 792 }
9915 else
9916 1512 sprintf(weapon_string[i],"zz%03d",i);
9917 2304 }
9918
9919 115 void init_item_drop_sets()
9920 {
9921
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9922 {
9923 // item_drop_sets[i] = default_item_drop_sets[0];
9924 29440 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9925 29440 }
9926
9927
2/2
✓ Branch 0 taken 1495 times.
✓ Branch 1 taken 115 times.
1610 for(int32_t i=0; i<isMAX; i++)
9928 {
9929 1495 item_drop_sets[i] = default_item_drop_sets[i];
9930
9931 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9932
2/2
✓ Branch 0 taken 14950 times.
✓ Branch 1 taken 1495 times.
16445 for(int32_t j=0; j<10; ++j)
9933 {
9934 14950 int32_t it = item_drop_sets[i].item[j];
9935
9936
3/4
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 4462 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672 times.
14950 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9937
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 9816 times.
10488 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9938 {
9939 672 item_drop_sets[i].chance[j+1]=0;
9940 672 }
9941
3/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 13818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 460 times.
14278 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9942 {
9943 item_drop_sets[i].chance[j+1]=0;
9944 }
9945
9946 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9947
2/2
✓ Branch 0 taken 14942 times.
✓ Branch 1 taken 8 times.
14950 if(itemsbuf[it].family == itype_misc)
9948 {
9949 // If a non-gameplay item was selected, then item drop was aborted.
9950 // Reflect this by increasing the 'Nothing' chance accordingly.
9951 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9952 8 item_drop_sets[i].chance[j+1]=0;
9953 8 }
9954 14950 }
9955 1495 }
9956 115 }
9957
9958 111 void init_favorites()
9959 {
9960
2/2
✓ Branch 0 taken 33300 times.
✓ Branch 1 taken 111 times.
33411 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9961 {
9962 33300 favorite_combos[i]=-1;
9963 33300 }
9964
9965
2/2
✓ Branch 0 taken 33300 times.
✓ Branch 1 taken 111 times.
33411 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9966 {
9967 33300 favorite_comboaliases[i]=-1;
9968 33300 }
9969 111 }
9970
9971 const char *ctype_name[cMAX]=
9972 {
9973 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9974 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9975 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9976 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9977 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9978 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9979 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9980 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9981 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9982 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9983 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9984 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9985 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9986 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9987 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9988 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9989 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9990 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9991 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9992 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9993 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9994 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9995 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9996 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9997 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9998 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9999 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
10000 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
10001
10002 };
10003
10004 202 int32_t init_combo_classes()
10005 {
10006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202 times.
202 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10007
2/2
✓ Branch 0 taken 36562 times.
✓ Branch 1 taken 202 times.
36764 for(int32_t i=0; i<cMAX; i++)
10008 {
10009 36562 combo_class_buf[i] = default_combo_classes[i];
10010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36562 times.
36562 if ( char const* nm = zi->getComboTypeName(i) )
10011 {
10012 36562 size_t len = strlen(nm);
10013
2/2
✓ Branch 0 taken 2339968 times.
✓ Branch 1 taken 36562 times.
2376530 for ( size_t q = 0; q < 64; q++ )
10014 {
10015
2/2
✓ Branch 0 taken 540350 times.
✓ Branch 1 taken 1799618 times.
2339968 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10016 2339968 }
10017 36562 }
10018 36562 }
10019
10020 202 return 0;
10021 }
10022
10023 89 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10024 {
10025
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 assert(v_herosprites < 6);
10026 //these are here to bypass compiler warnings about unused arguments
10027 89 cv_herosprites=cv_herosprites;
10028
10029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(keepdata)
10030 {
10031 89 zinit.hero_swim_speed=67; //default
10032 89 setupherotiles(zinit.heroAnimationStyle);
10033 89 setupherodefenses();
10034 89 setupherooffsets();
10035 89 }
10036
10037
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 76 times.
89 if(v_herosprites>=0)
10038 {
10039 word tile, tile2;
10040 byte flip, extend, dummy_byte;
10041
10042
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10043 {
10044
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10045 {
10046 return qe_invalid;
10047 }
10048
10049
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10050 {
10051 return qe_invalid;
10052 }
10053
10054
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10055 {
10056 return qe_invalid;
10057 }
10058
10059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10060 {
10061 304 walkspr[i][spr_tile]=(int32_t)tile;
10062 304 walkspr[i][spr_flip]=(int32_t)flip;
10063 304 walkspr[i][spr_extend]=(int32_t)extend;
10064 304 }
10065 304 }
10066
10067
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10068 {
10069
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10070 {
10071 return qe_invalid;
10072 }
10073
10074
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10075 {
10076 return qe_invalid;
10077 }
10078
10079
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10085 {
10086 304 stabspr[i][spr_tile]=(int32_t)tile;
10087 304 stabspr[i][spr_flip]=(int32_t)flip;
10088 304 stabspr[i][spr_extend]=(int32_t)extend;
10089 304 }
10090 304 }
10091
10092
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10093 {
10094
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10095 {
10096 return qe_invalid;
10097 }
10098
10099
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10100 {
10101 return qe_invalid;
10102 }
10103
10104
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10105 {
10106 return qe_invalid;
10107 }
10108
10109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10110 {
10111 304 slashspr[i][spr_tile]=(int32_t)tile;
10112 304 slashspr[i][spr_flip]=(int32_t)flip;
10113 304 slashspr[i][spr_extend]=(int32_t)extend;
10114 304 }
10115 304 }
10116
10117
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10118 {
10119
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10120 {
10121 return qe_invalid;
10122 }
10123
10124
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10125 {
10126 return qe_invalid;
10127 }
10128
10129
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10130 {
10131 return qe_invalid;
10132 }
10133
10134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10135 {
10136 304 floatspr[i][spr_tile]=(int32_t)tile;
10137 304 floatspr[i][spr_flip]=(int32_t)flip;
10138 304 floatspr[i][spr_extend]=(int32_t)extend;
10139 304 }
10140 304 }
10141
10142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>1)
10143 {
10144
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10145 {
10146
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10147 {
10148 return qe_invalid;
10149 }
10150
10151
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10152 {
10153 return qe_invalid;
10154 }
10155
10156
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10157 {
10158 return qe_invalid;
10159 }
10160
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10162 {
10163 304 swimspr[i][spr_tile]=(int32_t)tile;
10164 304 swimspr[i][spr_flip]=(int32_t)flip;
10165 304 swimspr[i][spr_extend]=(int32_t)extend;
10166 304 }
10167 304 }
10168 76 }
10169
10170
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10171 {
10172
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10173 {
10174 return qe_invalid;
10175 }
10176
10177
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10178 {
10179 return qe_invalid;
10180 }
10181
10182
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10183 {
10184 return qe_invalid;
10185 }
10186
10187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10188 {
10189 304 divespr[i][spr_tile]=(int32_t)tile;
10190 304 divespr[i][spr_flip]=(int32_t)flip;
10191 304 divespr[i][spr_extend]=(int32_t)extend;
10192 304 }
10193 304 }
10194
10195
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10196 {
10197
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10198 {
10199 return qe_invalid;
10200 }
10201
10202
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10203 {
10204 return qe_invalid;
10205 }
10206
10207
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10208 {
10209 return qe_invalid;
10210 }
10211
10212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10213 {
10214 304 poundspr[i][spr_tile]=(int32_t)tile;
10215 304 poundspr[i][spr_flip]=(int32_t)flip;
10216 304 poundspr[i][spr_extend]=(int32_t)extend;
10217 304 }
10218 304 }
10219
10220
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&tile,f,keepdata))
10221 {
10222 return qe_invalid;
10223 }
10224
10225 76 flip=0;
10226
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>0)
10228 {
10229
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&flip,f,keepdata))
10230 {
10231 return qe_invalid;
10232 }
10233 76 }
10234
10235
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&extend,f,keepdata))
10236 {
10237 return qe_invalid;
10238 }
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10241 {
10242 76 castingspr[spr_tile]=(int32_t)tile;
10243 76 castingspr[spr_flip]=(int32_t)flip;
10244 76 castingspr[spr_extend]=(int32_t)extend;
10245 76 }
10246
10247
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(v_herosprites>0)
10248 {
10249 76 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10250
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 76 times.
228 for(int32_t i=0; i<2; i++)
10251 {
10252
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 152 times.
456 for(int32_t j=0; j<num_holdsprs; j++)
10253 {
10254
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10265 {
10266 return qe_invalid;
10267 }
10268
10269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10270 {
10271 304 holdspr[i][j][spr_tile]=(int32_t)tile;
10272 304 holdspr[i][j][spr_flip]=(int32_t)flip;
10273 304 holdspr[i][j][spr_extend]=(int32_t)extend;
10274 304 }
10275 304 }
10276 152 }
10277 76 }
10278 else
10279 {
10280 for(int32_t i=0; i<2; i++)
10281 {
10282 if(!p_igetw(&tile,f,keepdata))
10283 {
10284 return qe_invalid;
10285 }
10286
10287 if(!p_igetw(&tile2,f,keepdata))
10288 {
10289 return qe_invalid;
10290 }
10291
10292 if(!p_getc(&extend,f,keepdata))
10293 {
10294 return qe_invalid;
10295 }
10296
10297 if(keepdata)
10298 {
10299 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10300 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10301 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10302 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10303 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10304 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10305 }
10306 }
10307 }
10308
10309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>2)
10310 {
10311
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10312 {
10313
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10314 {
10315 return qe_invalid;
10316 }
10317
10318
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10319 {
10320 return qe_invalid;
10321 }
10322
10323
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10324 {
10325 return qe_invalid;
10326 }
10327
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10329 {
10330 304 jumpspr[i][spr_tile]=(int32_t)tile;
10331 304 jumpspr[i][spr_flip]=(int32_t)flip;
10332 304 jumpspr[i][spr_extend]=(int32_t)extend;
10333 304 }
10334 304 }
10335 76 }
10336
10337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>3)
10338 {
10339
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10340 {
10341
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10342 {
10343 return qe_invalid;
10344 }
10345
10346
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10347 {
10348 return qe_invalid;
10349 }
10350
10351
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10352 {
10353 return qe_invalid;
10354 }
10355
10356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10357 {
10358 304 chargespr[i][spr_tile]=(int32_t)tile;
10359 304 chargespr[i][spr_flip]=(int32_t)flip;
10360 304 chargespr[i][spr_extend]=(int32_t)extend;
10361 304 }
10362 304 }
10363 76 }
10364
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>4)
10366 {
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!p_getc(&dummy_byte,f,keepdata))
10368 {
10369 return qe_invalid;
10370 }
10371
10372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10373 {
10374 76 zinit.hero_swim_speed=(byte)dummy_byte;
10375 76 }
10376 76 }
10377
10378
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(keepdata)
10379 {
10380 76 memset(frozenspr, 0, sizeof(frozenspr));
10381 76 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10382 76 memset(onfirespr, 0, sizeof(onfirespr));
10383 76 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10384 76 memset(diggingspr, 0, sizeof(diggingspr));
10385 76 memset(usingrodspr, 0, sizeof(usingrodspr));
10386 76 memset(usingcanespr, 0, sizeof(usingcanespr));
10387 76 memset(pushingspr, 0, sizeof(pushingspr));
10388 76 memset(liftingspr, 0, sizeof(liftingspr));
10389 76 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10390 76 memset(stunnedspr, 0, sizeof(stunnedspr));
10391 76 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10392 76 memset(fallingspr, 0, sizeof(fallingspr));
10393 76 memset(shockedspr, 0, sizeof(shockedspr));
10394 76 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10395 76 memset(pullswordspr, 0, sizeof(pullswordspr));
10396 76 memset(readingspr, 0, sizeof(readingspr));
10397 76 memset(slash180spr, 0, sizeof(slash180spr));
10398 76 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10399 76 memset(dashspr, 0, sizeof(dashspr));
10400 76 memset(bonkspr, 0, sizeof(bonkspr));
10401 76 memset(medallionsprs, 0, sizeof(medallionsprs));
10402 76 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10403 76 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10404
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t q = 0; q < 4; ++q)
10405 {
10406
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 304 times.
1216 for(int32_t p = 0; p < 3; ++p)
10407 {
10408 912 drowningspr[q][p] = divespr[q][p];
10409 912 drowning_lavaspr[q][p] = divespr[q][p];
10410 912 }
10411 304 }
10412 76 memset(sideswimspr, 0, sizeof(sideswimspr));
10413 76 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10414 76 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10415 76 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10416 76 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10417 76 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10418 76 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10419 76 }
10420 76 }
10421
10422
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
89 if(keepdata && FFCore.quest_format[vInitData] < 34)
10423 {
10424 89 bool fastswim = zinit.hero_swim_speed > 60;
10425 // '2/3' or '1/2'
10426 89 zinit.hero_swim_mult = fastswim ? 2 : 1;
10427 89 zinit.hero_swim_div = fastswim ? 3 : 2;
10428 89 }
10429 89 return 0;
10430 89 }
10431
10432 5100 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10433 {
10434 5100 arr[spr_tile] = tile;
10435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
5100 arr[spr_flip] = (flip > 3 ? 0 : flip);
10436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5100 times.
5100 arr[spr_extend] = (ext > 2 ? 0 : ext);
10437 5100 }
10438 //Used to read the player sprites as int32_t, not word.
10439 30 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10440 {
10441 //these are here to bypass compiler warnings about unused arguments
10442 30 cv_herosprites=cv_herosprites;
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(keepdata)
10445 {
10446 30 zinit.hero_swim_speed=67; //default
10447 30 setupherotiles(zinit.heroAnimationStyle);
10448 30 setupherodefenses();
10449 30 setupherooffsets();
10450 30 }
10451
10452 int32_t tile, tile2;
10453 byte flip, extend, dummy_byte;
10454
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>=0)
10456 {
10457
10458
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10459 {
10460
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10461 {
10462 return qe_invalid;
10463 }
10464
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10466 {
10467 return qe_invalid;
10468 }
10469
10470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10471 {
10472 return qe_invalid;
10473 }
10474
10475 120 if(keepdata)
10476 {
10477 120 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10478 120 }
10479 120 }
10480
10481
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10482 {
10483
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10484 {
10485 return qe_invalid;
10486 }
10487
10488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10489 {
10490 return qe_invalid;
10491 }
10492
10493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10494 {
10495 return qe_invalid;
10496 }
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10499 {
10500 120 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10501 120 }
10502 120 }
10503
10504
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10505 {
10506
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10507 {
10508 return qe_invalid;
10509 }
10510
10511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10512 {
10513 return qe_invalid;
10514 }
10515
10516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10517 {
10518 return qe_invalid;
10519 }
10520
10521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10522 {
10523 120 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10524 120 }
10525 120 }
10526
10527
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10528 {
10529
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10530 {
10531 return qe_invalid;
10532 }
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10535 {
10536 return qe_invalid;
10537 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10540 {
10541 return qe_invalid;
10542 }
10543
10544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10545 {
10546 120 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10547 120 }
10548 120 }
10549
10550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>1)
10551 {
10552
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10553 {
10554
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10555 {
10556 return qe_invalid;
10557 }
10558
10559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10560 {
10561 return qe_invalid;
10562 }
10563
10564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10565 {
10566 return qe_invalid;
10567 }
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10570 {
10571 120 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10572 120 }
10573 120 }
10574 30 }
10575
10576
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10577 {
10578
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10579 {
10580 return qe_invalid;
10581 }
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10584 {
10585 return qe_invalid;
10586 }
10587
10588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10589 {
10590 return qe_invalid;
10591 }
10592
10593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10594 {
10595 120 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10596 120 }
10597 120 }
10598
10599
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10600 {
10601
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10602 {
10603 return qe_invalid;
10604 }
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10607 {
10608 return qe_invalid;
10609 }
10610
10611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10612 {
10613 return qe_invalid;
10614 }
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10617 {
10618 120 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10619 120 }
10620 120 }
10621
10622
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tile,f,keepdata))
10623 {
10624 return qe_invalid;
10625 }
10626
10627 30 flip=0;
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>0)
10630 {
10631
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&flip,f,keepdata))
10632 {
10633 return qe_invalid;
10634 }
10635 30 }
10636
10637
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&extend,f,keepdata))
10638 {
10639 return qe_invalid;
10640 }
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(keepdata)
10643 {
10644 30 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10645 30 }
10646
10647
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(v_herosprites>0)
10648 {
10649 30 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10650
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 30 times.
90 for(int32_t i=0; i<2; i++)
10651 {
10652
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 60 times.
240 for(int32_t j=0; j<num_holdsprs; j++)
10653 {
10654
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&tile,f,keepdata))
10655 {
10656 return qe_invalid;
10657 }
10658
10659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(!p_getc(&flip,f,keepdata))
10660 {
10661 return qe_invalid;
10662 }
10663
10664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(!p_getc(&extend,f,keepdata))
10665 {
10666 return qe_invalid;
10667 }
10668
10669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(keepdata)
10670 {
10671 180 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10672 180 }
10673 180 }
10674 60 }
10675 30 }
10676 else
10677 {
10678 for(int32_t i=0; i<2; i++)
10679 {
10680 if(!p_igetl(&tile,f,keepdata))
10681 {
10682 return qe_invalid;
10683 }
10684
10685 if(!p_igetl(&tile2,f,keepdata))
10686 {
10687 return qe_invalid;
10688 }
10689
10690 if(!p_getc(&extend,f,keepdata))
10691 {
10692 return qe_invalid;
10693 }
10694
10695 if(keepdata)
10696 {
10697 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10698 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10699 }
10700 }
10701 }
10702
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>2)
10704 {
10705
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10706 {
10707
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10708 {
10709 return qe_invalid;
10710 }
10711
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10713 {
10714 return qe_invalid;
10715 }
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10718 {
10719 return qe_invalid;
10720 }
10721
10722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10723 {
10724 120 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10725 120 }
10726 120 }
10727 30 }
10728
10729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>3)
10730 {
10731
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t i=0; i<4; i++)
10732 {
10733
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10734 {
10735 return qe_invalid;
10736 }
10737
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10739 {
10740 return qe_invalid;
10741 }
10742
10743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10744 {
10745 return qe_invalid;
10746 }
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10749 {
10750 120 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10751 120 }
10752 120 }
10753 30 }
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(v_herosprites>4)
10756 {
10757
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&dummy_byte,f,keepdata))
10758 {
10759 return qe_invalid;
10760 }
10761
10762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(keepdata)
10763 {
10764 30 zinit.hero_swim_speed=(byte)dummy_byte;
10765 30 }
10766 30 }
10767
10768
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(v_herosprites>6)
10769 {
10770
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10771 {
10772
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10773 return qe_invalid;
10774
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10776 return qe_invalid;
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10779 return qe_invalid;
10780
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10782 {
10783 120 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 120 }
10785 120 }
10786
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10787 {
10788
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10789 return qe_invalid;
10790
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10792 return qe_invalid;
10793
10794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10795 return qe_invalid;
10796
10797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10798 {
10799 120 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10800 120 }
10801 120 }
10802
10803
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10804 {
10805
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10806 return qe_invalid;
10807
10808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10809 return qe_invalid;
10810
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10812 return qe_invalid;
10813
10814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10815 {
10816 120 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10817 120 }
10818 120 }
10819
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10820 {
10821
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10822 return qe_invalid;
10823
10824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10825 return qe_invalid;
10826
10827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10828 return qe_invalid;
10829
10830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10831 {
10832 120 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10833 120 }
10834 120 }
10835
10836
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10837 {
10838
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10839 return qe_invalid;
10840
10841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10842 return qe_invalid;
10843
10844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10845 return qe_invalid;
10846
10847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10848 {
10849 120 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10850 120 }
10851 120 }
10852
10853
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10856 return qe_invalid;
10857
10858
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10859 return qe_invalid;
10860
10861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10862 return qe_invalid;
10863
10864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10865 {
10866 120 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10867 120 }
10868 120 }
10869
10870
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10871 {
10872
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10876 return qe_invalid;
10877
10878
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
10879 return qe_invalid;
10880
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10882 {
10883 120 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 120 }
10885 120 }
10886
10887
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10888 {
10889
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10890 return qe_invalid;
10891
10892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
10893 return qe_invalid;
10894
10895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10899 {
10900 120 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10901 120 }
10902 120 }
10903
10904
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10905 {
10906
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10907 return qe_invalid;
10908
10909
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
10913 return qe_invalid;
10914
10915 120 byte frames = 0;
10916
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 112 times.
120 if(v_herosprites > 15)
10917 {
10918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if(!p_getc(&frames,f,keepdata))
10919 return qe_invalid;
10920 112 }
10921
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10923 {
10924 120 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10925 120 liftingspr[q][spr_frames] = frames;
10926 120 }
10927 120 }
10928
10929
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10930 {
10931
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10932 return qe_invalid;
10933
10934
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10935 return qe_invalid;
10936
10937
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
10938 return qe_invalid;
10939
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10941 {
10942 120 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10943 120 }
10944 120 }
10945
10946
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10947 {
10948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&tile,f,keepdata))
10949 return qe_invalid;
10950
10951
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10952 return qe_invalid;
10953
10954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10955 return qe_invalid;
10956
10957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10958 {
10959 120 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10960 120 }
10961 120 }
10962
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10963 {
10964
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10965 return qe_invalid;
10966
10967
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10968 return qe_invalid;
10969
10970
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
10971 return qe_invalid;
10972
10973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10974 {
10975 120 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10976 120 }
10977 120 }
10978
10979
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10980 {
10981
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10982 return qe_invalid;
10983
10984
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
10985 return qe_invalid;
10986
10987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
10988 return qe_invalid;
10989
10990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
10991 {
10992 120 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10993 120 }
10994 120 }
10995
10996
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
10997 {
10998
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
10999 return qe_invalid;
11000
11001
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11002 return qe_invalid;
11003
11004
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11005 return qe_invalid;
11006
11007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11008 {
11009 120 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11010 120 }
11011 120 }
11012
11013
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11014 {
11015
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11016 return qe_invalid;
11017
11018
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11019 return qe_invalid;
11020
11021
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11022 return qe_invalid;
11023
11024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11025 {
11026 120 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11027 120 }
11028 120 }
11029
11030
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11031 {
11032
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11033 return qe_invalid;
11034
11035
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11036 return qe_invalid;
11037
11038
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11042 {
11043 120 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11044 120 }
11045 120 }
11046
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11047 {
11048
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11049 return qe_invalid;
11050
11051
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11058 {
11059 120 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11060 120 }
11061 120 }
11062
11063
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11064 {
11065
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11066 return qe_invalid;
11067
11068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11069 return qe_invalid;
11070
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11072 return qe_invalid;
11073
11074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11075 {
11076 120 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11077 120 }
11078 120 }
11079
11080
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11081 {
11082
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11083 return qe_invalid;
11084
11085
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11086 return qe_invalid;
11087
11088
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11089 return qe_invalid;
11090
11091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11092 {
11093 120 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11094 120 }
11095 120 }
11096
11097
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11098 {
11099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&tile,f,keepdata))
11100 return qe_invalid;
11101
11102
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11103 return qe_invalid;
11104
11105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11106 return qe_invalid;
11107
11108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11109 {
11110 120 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11111 120 }
11112 120 }
11113
11114
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11115 {
11116
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11117 return qe_invalid;
11118
11119
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11120 return qe_invalid;
11121
11122
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11123 return qe_invalid;
11124
11125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11126 {
11127 120 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11128 120 }
11129 120 }
11130
11131
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11132 {
11133
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11134 return qe_invalid;
11135
11136
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11137 return qe_invalid;
11138
11139
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11140 return qe_invalid;
11141
11142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11143 {
11144 120 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11145 120 }
11146 120 }
11147
11148
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11149 {
11150
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11151 return qe_invalid;
11152
11153
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&flip,f,keepdata))
11154 return qe_invalid;
11155
11156
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_getc(&extend,f,keepdata))
11157 return qe_invalid;
11158
11159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11160 {
11161 120 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11162 120 }
11163 120 }
11164
11165
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
120 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11166 {
11167
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&tile,f,keepdata))
11168 return qe_invalid;
11169
11170
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_getc(&flip,f,keepdata))
11171 return qe_invalid;
11172
11173
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_getc(&extend,f,keepdata))
11174 return qe_invalid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(keepdata)
11177 {
11178 90 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11179 90 }
11180 90 }
11181 30 }
11182 else if(keepdata)
11183 {
11184 memset(frozenspr, 0, sizeof(frozenspr));
11185 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11186 memset(onfirespr, 0, sizeof(onfirespr));
11187 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11188 memset(diggingspr, 0, sizeof(diggingspr));
11189 memset(usingrodspr, 0, sizeof(usingrodspr));
11190 memset(usingcanespr, 0, sizeof(usingcanespr));
11191 memset(pushingspr, 0, sizeof(pushingspr));
11192 memset(liftingspr, 0, sizeof(liftingspr));
11193 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11194 memset(stunnedspr, 0, sizeof(stunnedspr));
11195 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11196 memset(fallingspr, 0, sizeof(fallingspr));
11197 memset(shockedspr, 0, sizeof(shockedspr));
11198 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11199 memset(pullswordspr, 0, sizeof(pullswordspr));
11200 memset(readingspr, 0, sizeof(readingspr));
11201 memset(slash180spr, 0, sizeof(slash180spr));
11202 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11203 memset(dashspr, 0, sizeof(dashspr));
11204 memset(bonkspr, 0, sizeof(bonkspr));
11205 memset(medallionsprs, 0, sizeof(medallionsprs));
11206 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11207 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11208 for(int32_t q = 0; q < 4; ++q)
11209 {
11210 for(int32_t p = 0; p < 3; ++p)
11211 {
11212 drowningspr[q][p] = divespr[q][p];
11213 drowning_lavaspr[q][p] = divespr[q][p];
11214 }
11215 }
11216 }
11217
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 8)
11218 {
11219
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11220 {
11221
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11222 return qe_invalid;
11223
11224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11225 return qe_invalid;
11226
11227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11228 return qe_invalid;
11229
11230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11231 {
11232 120 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11233 120 }
11234 120 }
11235 30 }
11236 else if (keepdata)
11237 {
11238 memset(sideswimspr, 0, sizeof(sideswimspr));
11239 }
11240
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 9)
11241 {
11242
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11243 {
11244
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11245 return qe_invalid;
11246
11247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11248 return qe_invalid;
11249
11250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11251 return qe_invalid;
11252
11253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11254 {
11255 120 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11256 120 }
11257 120 }
11258
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11259 {
11260
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11261 return qe_invalid;
11262
11263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11264 return qe_invalid;
11265
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11267 return qe_invalid;
11268
11269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11270 {
11271 120 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11272 120 }
11273 120 }
11274
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11275 {
11276
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11277 return qe_invalid;
11278
11279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11280 return qe_invalid;
11281
11282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11283 return qe_invalid;
11284
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11286 {
11287 120 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11288 120 }
11289 120 }
11290
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11291 {
11292
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11293 return qe_invalid;
11294
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11296 return qe_invalid;
11297
11298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11299 return qe_invalid;
11300
11301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11302 {
11303 120 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11304 120 }
11305 120 }
11306 30 }
11307 else if (keepdata)
11308 {
11309 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11310 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11311 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11312 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11313 }
11314
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 10)
11315 {
11316
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11317 {
11318 int32_t hmr;
11319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_igetl(&hmr,f,keepdata))
11320 return qe_invalid;
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11323 {
11324 120 hammeroffsets[q] = hmr;
11325 120 }
11326 120 }
11327 30 }
11328 else if (keepdata)
11329 {
11330 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11331 }
11332
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 11)
11333 {
11334
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
120 for(int32_t q = 0; q < 3; ++q)
11335 {
11336
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&tile,f,keepdata))
11337 return qe_invalid;
11338
11339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!p_getc(&flip,f,keepdata))
11340 return qe_invalid;
11341
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!p_getc(&extend,f,keepdata))
11343 return qe_invalid;
11344
11345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(keepdata)
11346 {
11347 90 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11348 90 }
11349 90 }
11350 30 }
11351 else if (keepdata)
11352 {
11353 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11354 }
11355
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 12)
11356 {
11357
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tile,f,keepdata))
11358 return qe_invalid;
11359
11360
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&flip,f,keepdata))
11361 return qe_invalid;
11362
11363
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_getc(&extend,f,keepdata))
11364 return qe_invalid;
11365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (keepdata)
11366 {
11367 30 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11368 30 }
11369
11370 30 }
11371 else if (keepdata)
11372 {
11373 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11374 }
11375
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 13)
11376 {
11377
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11378 {
11379
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11380 return qe_invalid;
11381
11382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11383 return qe_invalid;
11384
11385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11386 return qe_invalid;
11387
11388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11389 {
11390 120 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11391 120 }
11392 120 }
11393 30 }
11394 else if (keepdata)
11395 {
11396 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11397 }
11398
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 14)
11399 {
11400
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for(int32_t q = 0; q < 4; ++q)
11401 {
11402
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!p_igetl(&tile,f,keepdata))
11403 return qe_invalid;
11404
11405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&flip,f,keepdata))
11406 return qe_invalid;
11407
11408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(!p_getc(&extend,f,keepdata))
11409 return qe_invalid;
11410
11411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(keepdata)
11412 {
11413 120 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11414 120 }
11415 120 }
11416 30 }
11417 else if (keepdata)
11418 {
11419 memset(revslashspr, 0, sizeof(revslashspr));
11420 }
11421
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (v_herosprites > 7)
11422 {
11423 30 int32_t num_defense = wMax;
11424 30 byte def = 0;
11425
11426 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11427 /*if(v_herosprites > [x])
11428 * {
11429 * num_defense = 146 //value of wMax on version 8
11430 * }
11431 */
11432
11433
2/2
✓ Branch 0 taken 4380 times.
✓ Branch 1 taken 30 times.
4410 for (int32_t q = 0; q < num_defense; q++)
11434 {
11435
1/2
✓ Branch 0 taken 4380 times.
✗ Branch 1 not taken.
4380 if (!p_getc(&def, f, keepdata))
11436 return qe_invalid;
11437
11438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4380 times.
4380 if (keepdata)
11439 {
11440 4380 hero_defence[q] = def;
11441 4380 }
11442 4380 }
11443 30 }
11444 else if (keepdata)
11445 {
11446 int32_t num_defense = wMax;
11447 for (int32_t q = 0; q < num_defense; q++)
11448 {
11449 hero_defence[q] = 0;
11450 }
11451 }
11452 30 }
11453
11454
3/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5 times.
30 if(keepdata && FFCore.quest_format[vInitData] < 34)
11455 {
11456 5 bool fastswim = zinit.hero_swim_speed > 60;
11457 // '2/3' or '1/2'
11458 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11459 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11460 5 }
11461 30 return 0;
11462 30 }
11463
11464
11465 106 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11466 {
11467 //these are here to bypass compiler warnings about unused arguments
11468 106 Header=Header;
11469
11470 dword dummy;
11471 106 word s_version=0, s_cversion=0;
11472
11473 //section version info
11474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
11475 {
11476 return qe_invalid;
11477 }
11478
11479 106 FFCore.quest_format[vHeroSprites] = s_version;
11480
11481 //al_trace("Player sprites version %d\n", s_version);
11482
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
11483 {
11484 return qe_invalid;
11485 }
11486
11487 //section size
11488
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy,f,true))
11489 {
11490 return qe_invalid;
11491 }
11492
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if ( s_version >= 6 )
11493 {
11494 //al_trace("Reading Player Sprites v6\n");
11495 30 return readherosprites3(f, s_version, dummy, keepdata);
11496 }
11497 76 else return readherosprites2(f, s_version, dummy, keepdata);
11498 106 }
11499
11500 106 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11501 {
11502 int32_t dummy;
11503 106 word s_version=0, s_cversion=0;
11504
11505 //section version info
11506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
11507 {
11508 return qe_invalid;
11509 }
11510
11511 106 FFCore.quest_format[vSubscreen] = s_version;
11512
11513 //al_trace("Subscreens version %d\n", s_version);
11514
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
11515 {
11516 return qe_invalid;
11517 }
11518
11519 //section size
11520
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy,f,true))
11521 {
11522 return qe_invalid;
11523 }
11524
11525 //finally... section data
11526
2/2
✓ Branch 0 taken 13568 times.
✓ Branch 1 taken 106 times.
13674 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11527 {
11528 13568 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11529
11530
1/2
✓ Branch 0 taken 13568 times.
✗ Branch 1 not taken.
13568 if(ret!=0) return ret;
11531 13568 }
11532
11533 106 return 0;
11534 106 }
11535
11536 13568 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11537 {
11538 13568 int32_t numsub=0;
11539 13568 byte temp_ss=0;
11540 subscreen_object temp_sub_stack;
11541 13568 subscreen_object *temp_sub = &temp_sub_stack;
11542
11543 char tempname[64];
11544
11545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13568 times.
13568 if(!pfread(tempname,64,f,true))
11546 {
11547 return qe_invalid;
11548 }
11549
11550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13568 times.
13568 if(s_version > 1)
11551 {
11552
1/2
✓ Branch 0 taken 13568 times.
✗ Branch 1 not taken.
13568 if(!p_getc(&temp_ss,f,keepdata))
11553 {
11554 return qe_invalid;
11555 }
11556 13568 }
11557
11558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13568 times.
13568 if(s_version < 4)
11559 {
11560 uint8_t tmp=0;
11561
11562 if(!p_getc(&tmp,f,true))
11563 {
11564 return qe_invalid;
11565 }
11566
11567 numsub = (int32_t)tmp;
11568 }
11569 else
11570 {
11571 word tmp;
11572
11573
1/2
✓ Branch 0 taken 13568 times.
✗ Branch 1 not taken.
13568 if(!p_igetw(&tmp, f, true))
11574 {
11575 return qe_invalid;
11576 }
11577
11578 13568 numsub = (int32_t)tmp;
11579 }
11580
11581 int32_t j;
11582
11583
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38130 times.
✓ Branch 2 taken 24562 times.
✓ Branch 3 taken 13568 times.
38130 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11584 {
11585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24562 times.
24562 if(keepdata)
11586 {
11587 24562 memset(temp_sub,0,sizeof(subscreen_object));
11588
11589
2/2
✓ Branch 0 taken 1199 times.
✓ Branch 1 taken 23363 times.
24562 switch(custom_subscreen[i].objects[j].type)
11590 {
11591 case ssoTEXT:
11592 case ssoTEXTBOX:
11593 case ssoCURRENTITEMTEXT:
11594 case ssoCURRENTITEMCLASSTEXT:
11595
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
1199 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11596
11597 //fall through
11598 default:
11599 24562 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11600 24562 break;
11601 }
11602 24562 }
11603
11604
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->type),f,true))
11605 {
11606 return qe_invalid;
11607 }
11608
11609
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->pos),f,keepdata))
11610 {
11611 return qe_invalid;
11612 }
11613
11614
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(s_version < 5)
11615 {
11616 switch(temp_sub->pos)
11617 {
11618 case 0:
11619 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11620 break;
11621
11622 case 1:
11623 temp_sub->pos = sspUP;
11624 break;
11625
11626 case 2:
11627 temp_sub->pos = sspDOWN;
11628 break;
11629
11630 default:
11631 temp_sub->pos = 0;
11632 }
11633 }
11634
11635
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->x),f,keepdata))
11636 {
11637 return qe_invalid;
11638 }
11639
11640
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->y),f,keepdata))
11641 {
11642 return qe_invalid;
11643 }
11644
11645
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->w),f,keepdata))
11646 {
11647 return qe_invalid;
11648 }
11649
11650
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->h),f,keepdata))
11651 {
11652 return qe_invalid;
11653 }
11654
11655
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11656 {
11657 return qe_invalid;
11658 }
11659
11660
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11661 {
11662 return qe_invalid;
11663 }
11664
11665
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11666 {
11667 return qe_invalid;
11668 }
11669
11670
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11671 {
11672 return qe_invalid;
11673 }
11674
11675
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11676 {
11677 return qe_invalid;
11678 }
11679
11680
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11681 {
11682 return qe_invalid;
11683 }
11684
11685
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11686 {
11687 return qe_invalid;
11688 }
11689
11690
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11691 {
11692 return qe_invalid;
11693 }
11694
11695
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11696 {
11697 return qe_invalid;
11698 }
11699
11700
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11701 {
11702 return qe_invalid;
11703 }
11704
11705
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11706 {
11707 return qe_invalid;
11708 }
11709
11710
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11711 {
11712 return qe_invalid;
11713 }
11714
11715
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11716 {
11717 return qe_invalid;
11718 }
11719
11720
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11721 {
11722 return qe_invalid;
11723 }
11724
11725
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11726 {
11727 return qe_invalid;
11728 }
11729
11730
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11731 {
11732 return qe_invalid;
11733 }
11734
11735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24562 times.
24562 if(s_version < 2)
11736 {
11737 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11738 {
11739 return qe_invalid;
11740 }
11741
11742 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11743 {
11744 return qe_invalid;
11745 }
11746
11747 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11748 {
11749 return qe_invalid;
11750 }
11751 }
11752 else
11753 {
11754
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->speed),f,keepdata))
11755 {
11756 return qe_invalid;
11757 }
11758
11759
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_getc(&(temp_sub->delay),f,keepdata))
11760 {
11761 return qe_invalid;
11762 }
11763
11764
1/2
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
24562 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11765 {
11766 return qe_invalid;
11767 }
11768 }
11769
11770 24562 int32_t temp_size=0;
11771
11772 // bool deletets = false;
11773
4/4
✓ Branch 0 taken 10334 times.
✓ Branch 1 taken 1818 times.
✓ Branch 2 taken 12261 times.
✓ Branch 3 taken 149 times.
24562 switch(temp_sub->type)
11774 {
11775 case ssoTEXT:
11776 case ssoTEXTBOX:
11777 case ssoCURRENTITEMTEXT:
11778 case ssoCURRENTITEMCLASSTEXT:
11779 word temptempsize;
11780 /*uint8_t temp1;
11781 uint8_t temp2;
11782 temp2 = 0;
11783 if(!p_getc(&temp1,f,true))
11784 {
11785 return qe_invalid;
11786 }
11787 if(temp1)
11788 {
11789
11790 if(!p_getc(&temp2,f,true))
11791 {
11792 return qe_invalid;
11793 }
11794 }*/
11795
11796
1/2
✓ Branch 0 taken 1818 times.
✗ Branch 1 not taken.
1818 if(!p_igetw(&temptempsize,f,true))
11797 {
11798 return qe_invalid;
11799 }
11800
11801 //temptempsize = temp1 + (temp2 << 8);
11802 1818 temp_size = (int32_t)temptempsize;
11803
11804 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1818 times.
1818 if(keepdata)
11806 {
11807 1818 uint32_t char_length = temp_size+2;
11808 1818 temp_sub->dp1 = new char[char_length]; //memory not freed
11809 1818 ((char*)temp_sub->dp1)[char_length - 1] = '\0';
11810
11811 //deletets = true; //obsolete
11812 1818 }
11813
11814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1818 times.
1818 if(temp_size)
11815 {
11816
1/2
✓ Branch 0 taken 1818 times.
✗ Branch 1 not taken.
1818 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11817 {
11818 return qe_invalid;
11819 }
11820 1818 }
11821
11822 1818 break;
11823
11824 case ssoLIFEMETER:
11825
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11826 temp_sub->d3 = 1;
11827
11828
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11829 {
11830 return qe_invalid;
11831 }
11832
11833 149 break;
11834
11835
11836 case ssoCURRENTITEM:
11837
11838
1/2
✓ Branch 0 taken 10334 times.
✗ Branch 1 not taken.
10334 if(s_version < 6)
11839 {
11840 switch(temp_sub->d1)
11841 {
11842 case ssiBOMB:
11843 temp_sub->d1 = itype_bomb;
11844 break;
11845
11846 case ssiSWORD:
11847 temp_sub->d1 = itype_sword;
11848 break;
11849
11850 case ssiSHIELD:
11851 temp_sub->d1 = itype_shield;
11852 break;
11853
11854 case ssiCANDLE:
11855 temp_sub->d1 = itype_candle;
11856 break;
11857
11858 case ssiLETTER:
11859 temp_sub->d1 = itype_letter;
11860 break;
11861
11862 case ssiPOTION:
11863 temp_sub->d1 = itype_potion;
11864 break;
11865
11866 case ssiLETTERPOTION:
11867 temp_sub->d1 = itype_letterpotion;
11868 break;
11869
11870 case ssiBOW:
11871 temp_sub->d1 = itype_bow;
11872 break;
11873
11874 case ssiARROW:
11875 temp_sub->d1 = itype_arrow;
11876 break;
11877
11878 case ssiBOWANDARROW:
11879 temp_sub->d1 = itype_bowandarrow;
11880 break;
11881
11882 case ssiBAIT:
11883 temp_sub->d1 = itype_bait;
11884 break;
11885
11886 case ssiRING:
11887 temp_sub->d1 = itype_ring;
11888 break;
11889
11890 case ssiBRACELET:
11891 temp_sub->d1 = itype_bracelet;
11892 break;
11893
11894 case ssiMAP:
11895 temp_sub->d1 = itype_map;
11896 break;
11897
11898 case ssiCOMPASS:
11899 temp_sub->d1 = itype_compass;
11900 break;
11901
11902 case ssiBOSSKEY:
11903 temp_sub->d1 = itype_bosskey;
11904 break;
11905
11906 case ssiMAGICKEY:
11907 temp_sub->d1 = itype_magickey;
11908 break;
11909
11910 case ssiBRANG:
11911 temp_sub->d1 = itype_brang;
11912 break;
11913
11914 case ssiWAND:
11915 temp_sub->d1 = itype_wand;
11916 break;
11917
11918 case ssiRAFT:
11919 temp_sub->d1 = itype_raft;
11920 break;
11921
11922 case ssiLADDER:
11923 temp_sub->d1 = itype_ladder;
11924 break;
11925
11926 case ssiWHISTLE:
11927 temp_sub->d1 = itype_whistle;
11928 break;
11929
11930 case ssiBOOK:
11931 temp_sub->d1 = itype_book;
11932 break;
11933
11934 case ssiWALLET:
11935 temp_sub->d1 = itype_wallet;
11936 break;
11937
11938 case ssiSBOMB:
11939 temp_sub->d1 = itype_sbomb;
11940 break;
11941
11942 case ssiHCPIECE:
11943 temp_sub->d1 = itype_heartpiece;
11944 break;
11945
11946 case ssiAMULET:
11947 temp_sub->d1 = itype_amulet;
11948 break;
11949
11950 case ssiFLIPPERS:
11951 temp_sub->d1 = itype_flippers;
11952 break;
11953
11954 case ssiHOOKSHOT:
11955 temp_sub->d1 = itype_hookshot;
11956 break;
11957
11958 case ssiLENS:
11959 temp_sub->d1 = itype_lens;
11960 break;
11961
11962 case ssiHAMMER:
11963 temp_sub->d1 = itype_hammer;
11964 break;
11965
11966 case ssiBOOTS:
11967 temp_sub->d1 = itype_boots;
11968 break;
11969
11970 case ssiDIVINEFIRE:
11971 temp_sub->d1 = itype_divinefire;
11972 break;
11973
11974 case ssiDIVINEESCAPE:
11975 temp_sub->d1 = itype_divineescape;
11976 break;
11977
11978 case ssiDIVINEPROTECTION:
11979 temp_sub->d1 = itype_divineprotection;
11980 break;
11981
11982 case ssiQUIVER:
11983 temp_sub->d1 = itype_quiver;
11984 break;
11985
11986 case ssiBOMBBAG:
11987 temp_sub->d1 = itype_bombbag;
11988 break;
11989
11990 case ssiCBYRNA:
11991 temp_sub->d1 = itype_cbyrna;
11992 break;
11993
11994 case ssiROCS:
11995 temp_sub->d1 = itype_rocs;
11996 break;
11997
11998 case ssiHOVERBOOTS:
11999 temp_sub->d1 = itype_hoverboots;
12000 break;
12001
12002 case ssiSPINSCROLL:
12003 temp_sub->d1 = itype_spinscroll;
12004 break;
12005
12006 case ssiCROSSSCROLL:
12007 temp_sub->d1 = itype_crossscroll;
12008 break;
12009
12010 case ssiQUAKESCROLL:
12011 temp_sub->d1 = itype_quakescroll;
12012 break;
12013
12014 case ssiWHISPRING:
12015 temp_sub->d1 = itype_whispring;
12016 break;
12017
12018 case ssiCHARGERING:
12019 temp_sub->d1 = itype_chargering;
12020 break;
12021
12022 case ssiPERILSCROLL:
12023 temp_sub->d1 = itype_perilscroll;
12024 break;
12025
12026 case ssiWEALTHMEDAL:
12027 temp_sub->d1 = itype_wealthmedal;
12028 break;
12029
12030 case ssiHEARTRING:
12031 temp_sub->d1 = itype_heartring;
12032 break;
12033
12034 case ssiMAGICRING:
12035 temp_sub->d1 = itype_magicring;
12036 break;
12037
12038 case ssiSPINSCROLL2:
12039 temp_sub->d1 = itype_spinscroll2;
12040 break;
12041
12042 case ssiQUAKESCROLL2:
12043 temp_sub->d1 = itype_quakescroll2;
12044 break;
12045
12046 case ssiAGONY:
12047 temp_sub->d1 = itype_agony;
12048 break;
12049
12050 case ssiSTOMPBOOTS:
12051 temp_sub->d1 = itype_stompboots;
12052 break;
12053
12054 case ssiWHIMSICALRING:
12055 temp_sub->d1 = itype_whimsicalring;
12056 break;
12057
12058 case ssiPERILRING:
12059 temp_sub->d1 = itype_perilring;
12060 break;
12061
12062 default:
12063 temp_sub->d1 += itype_custom1 - ssiMAX;
12064 }
12065 }
12066
12067 //fall-through
12068 default:
12069
1/2
✓ Branch 0 taken 22595 times.
✗ Branch 1 not taken.
22595 if(!p_getc(&(temp_sub->dp1),f,keepdata))
12070 {
12071 return qe_invalid;
12072 }
12073
12074 22595 break;
12075 }
12076
12077
2/2
✓ Branch 0 taken 15962 times.
✓ Branch 1 taken 8600 times.
24562 if(s_version < 7)
12078 {
12079
3/3
✓ Branch 0 taken 7941 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8600 switch(temp_sub->type)
12080 {
12081 case ssoMAGICGAUGE:
12082 {
12083
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
12084 192 temp_sub->d9 = -1; //-1 now represents 'always'
12085 227 break;
12086 }
12087 case ssoLIFEGAUGE:
12088 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12089 432 break;
12090 }
12091 8600 }
12092
12093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24562 times.
24562 if(keepdata)
12094 {
12095
3/3
✓ Branch 0 taken 1818 times.
✓ Branch 1 taken 21657 times.
✓ Branch 2 taken 1087 times.
24562 switch(temp_sub->type)
12096 {
12097 case ssoTEXT:
12098 case ssoTEXTBOX:
12099 case ssoCURRENTITEMTEXT:
12100 case ssoCURRENTITEMCLASSTEXT:
12101
1/4
✓ Branch 0 taken 1818 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1818 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
12102
12103 1818 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12104 1818 custom_subscreen[i].objects[j].dp1 = NULL;
12105 1818 custom_subscreen[i].objects[j].dp1 = new char[temp_size+2];
12106 1818 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
12107 1818 break;
12108
12109 case ssoCOUNTER:
12110
1/2
✓ Branch 0 taken 1087 times.
✗ Branch 1 not taken.
1087 if(s_version<3)
12111 {
12112 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12113 temp_sub->d8=0;
12114 }
12115
12116 default:
12117 22744 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12118 22744 break;
12119 }
12120
12121 24562 custom_subscreen[i].name[0] = '\0';
12122 24562 strncat(custom_subscreen[i].name, tempname, 64 - 1);
12123 24562 custom_subscreen[i].ss_type = temp_ss;
12124 24562 }
12125 24562 }
12126
12127
2/2
✓ Branch 0 taken 3448846 times.
✓ Branch 1 taken 13568 times.
3462414 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12128 {
12129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3448846 times.
3448846 if(keepdata)
12130 {
12131 //clear all unused object in this subscreen -DD
12132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3448846 times.
3448846 switch(custom_subscreen[i].objects[j].type)
12133 {
12134 case ssoTEXT:
12135 case ssoTEXTBOX:
12136 case ssoCURRENTITEMTEXT:
12137 case ssoCURRENTITEMCLASSTEXT:
12138 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12139
12140 //fall through
12141 default:
12142 3448846 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12143 3448846 break;
12144 }
12145 3448846 }
12146 3448846 }
12147
12148 13568 return 0;
12149 13568 }
12150
12151 2944 void reset_subscreen(subscreen_group *tempss)
12152 {
12153
2/2
✓ Branch 0 taken 753664 times.
✓ Branch 1 taken 2944 times.
756608 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12154 {
12155
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 753522 times.
753664 switch(tempss->objects[i].type)
12156 {
12157 case ssoTEXT:
12158 case ssoTEXTBOX:
12159 case ssoCURRENTITEMTEXT:
12160 case ssoCURRENTITEMCLASSTEXT:
12161
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12162
12163 //fall through
12164 default:
12165 753664 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12166 753664 break;
12167 }
12168 753664 }
12169 2944 }
12170
12171 23 void reset_subscreens()
12172 {
12173
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 23 times.
2967 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12174 {
12175 2944 reset_subscreen(&custom_subscreen[i]);
12176 2944 }
12177 23 }
12178
12179 23 int32_t setupsubscreens()
12180 {
12181 23 reset_subscreens();
12182 23 int32_t tempsubscreen=zinit.subscreen;
12183 subscreen_object *tempsub;
12184
12185
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tempsubscreen>=ssdtMAX)
12186 {
12187 tempsubscreen=0;
12188 }
12189
12190
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 switch(tempsubscreen)
12191 {
12192 case ssdtOLD:
12193 case ssdtNEWSUBSCR:
12194 case ssdtREV2:
12195 case ssdtBSZELDA:
12196 case ssdtBSZELDAMODIFIED:
12197 case ssdtBSZELDAENHANCED:
12198 case ssdtBSZELDACOMPLETE:
12199 {
12200 23 tempsub = default_subscreen_active[tempsubscreen][0];
12201 int32_t i;
12202
12203
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12204 {
12205
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1431 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12206 {
12207 case ssoTEXT:
12208 case ssoTEXTBOX:
12209 case ssoCURRENTITEMTEXT:
12210 case ssoCURRENTITEMCLASSTEXT:
12211
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12212
12213 64 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12214 64 custom_subscreen[0].objects[i].dp1 = NULL;
12215 64 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12216 64 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12217 64 break;
12218
12219 case ssoLIFEMETER:
12220 {
12221 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12222
12223 if(get_bit(deprecated_rules, 12) != 0)
12224 custom_subscreen[0].objects[i].d3=1;
12225 else
12226 custom_subscreen[0].objects[i].d3=0;
12227
12228 break;
12229 }
12230 /*
12231 case ssoTRIFRAME:
12232 {
12233 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12234 custom_subscreen[0].objects[i].d1 = 8594;
12235 custom_subscreen[0].objects[i].d2 = 8;
12236 custom_subscreen[0].objects[i].d3 = 8771;
12237 custom_subscreen[0].objects[i].d4 = 8;
12238 custom_subscreen[0].objects[i].d5 = 1;
12239 custom_subscreen[0].objects[i].d6 = 1;
12240 break;
12241 }*/
12242
12243 default:
12244 1431 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12245 1431 break;
12246 }
12247 1495 }
12248
12249 23 custom_subscreen[0].ss_type=sstACTIVE;
12250 23 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12251 23 tempsub = default_subscreen_active[tempsubscreen][1];
12252
12253
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12254 {
12255
2/3
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1412 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12256 {
12257 case ssoTEXT:
12258 case ssoTEXTBOX:
12259 case ssoCURRENTITEMTEXT:
12260 case ssoCURRENTITEMCLASSTEXT:
12261
1/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12262
12263 83 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12264 83 custom_subscreen[1].objects[i].dp1 = NULL;
12265 83 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12266 83 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12267 83 break;
12268
12269 case ssoLIFEMETER:
12270 {
12271 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12272
12273 if(get_bit(deprecated_rules, 12) != 0)
12274 custom_subscreen[1].objects[i].d3=1;
12275 else
12276 custom_subscreen[1].objects[i].d3=0;
12277
12278 break;
12279 }
12280 /*
12281 case ssoTRIFRAME:
12282 {
12283 custom_subscreen[1].objects[i].d1 = 8594;
12284 custom_subscreen[1].objects[i].d2 = 8;
12285 custom_subscreen[1].objects[i].d3 = 8771;
12286 custom_subscreen[1].objects[i].d4 = 8;
12287 custom_subscreen[1].objects[i].d5 = 1;
12288 custom_subscreen[1].objects[i].d6 = 1;
12289 break;
12290 }*/
12291
12292 default:
12293 1412 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12294 1412 break;
12295 }
12296 1495 }
12297
12298 23 custom_subscreen[1].ss_type=sstACTIVE;
12299 23 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12300 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12301 23 tempsub = default_subscreen_passive[tempsubscreen][0];
12302
12303
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 23 times.
483 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12304 {
12305
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 23 times.
460 switch(tempsub[i].type)
12306 {
12307 case ssoTEXT:
12308 case ssoTEXTBOX:
12309 case ssoCURRENTITEMTEXT:
12310 case ssoCURRENTITEMCLASSTEXT:
12311
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12312
12313 69 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12314 69 custom_subscreen[2].objects[i].dp1 = NULL;
12315 69 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12316 69 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12317 69 break;
12318
12319 case ssoLIFEMETER:
12320 {
12321 23 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12322
12323
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12324 7 custom_subscreen[2].objects[i].d3=1;
12325 else
12326 16 custom_subscreen[2].objects[i].d3=0;
12327
12328 23 break;
12329 }
12330
12331 default:
12332 368 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12333 368 break;
12334 }
12335 460 }
12336
12337 23 custom_subscreen[2].ss_type=sstPASSIVE;
12338 23 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12339 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12340 23 tempsub = default_subscreen_passive[tempsubscreen][1];
12341
12342
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 23 times.
460 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12343 {
12344
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 23 times.
437 switch(tempsub[i].type)
12345 {
12346 case ssoTEXT:
12347 case ssoTEXTBOX:
12348 case ssoCURRENTITEMTEXT:
12349 case ssoCURRENTITEMCLASSTEXT:
12350
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12351
12352 69 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12353 69 custom_subscreen[3].objects[i].dp1 = NULL;
12354 69 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12355 69 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12356 69 break;
12357
12358 case ssoLIFEMETER:
12359 {
12360 23 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12361
12362
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12363 7 custom_subscreen[3].objects[i].d3=1;
12364 else
12365 16 custom_subscreen[3].objects[i].d3=0;
12366
12367 23 break;
12368 }
12369
12370 default:
12371 345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12372 345 break;
12373 }
12374 437 }
12375
12376 23 custom_subscreen[3].ss_type=sstPASSIVE;
12377 23 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12378 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12379 23 break;
12380 }
12381
12382 case ssdtZ3:
12383 {
12384 tempsub = z3_active_a;
12385 int32_t i;
12386
12387 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12388 {
12389 switch(tempsub[i].type)
12390 {
12391 case ssoTEXT:
12392 case ssoTEXTBOX:
12393 case ssoCURRENTITEMTEXT:
12394 case ssoCURRENTITEMCLASSTEXT:
12395 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12396
12397 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12398 custom_subscreen[0].objects[i].dp1 = NULL;
12399 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12400 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12401 break;
12402
12403 case ssoLIFEMETER:
12404 {
12405 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12406
12407 if(get_bit(deprecated_rules, 12) != 0)
12408 custom_subscreen[0].objects[i].d3=1;
12409 else
12410 custom_subscreen[0].objects[i].d3=0;
12411
12412 break;
12413 }
12414
12415 default:
12416 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12417 break;
12418 }
12419 }
12420
12421 custom_subscreen[0].ss_type=sstACTIVE;
12422 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12423 tempsub = z3_active_ab;
12424
12425 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12426 {
12427 switch(tempsub[i].type)
12428 {
12429 case ssoTEXT:
12430 case ssoTEXTBOX:
12431 case ssoCURRENTITEMTEXT:
12432 case ssoCURRENTITEMCLASSTEXT:
12433 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12434
12435 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12436 custom_subscreen[1].objects[i].dp1 = NULL;
12437 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12438 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12439 break;
12440
12441 case ssoLIFEMETER:
12442 {
12443 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12444
12445 if(get_bit(deprecated_rules, 12) != 0)
12446 custom_subscreen[1].objects[i].d3=1;
12447 else
12448 custom_subscreen[1].objects[i].d3=0;
12449
12450 break;
12451 }
12452
12453 default:
12454 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12455 break;
12456 }
12457 }
12458
12459 custom_subscreen[1].ss_type=sstACTIVE;
12460 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12461 tempsub = z3_passive_a;
12462
12463 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12464 {
12465 switch(tempsub[i].type)
12466 {
12467 case ssoTEXT:
12468 case ssoTEXTBOX:
12469 case ssoCURRENTITEMTEXT:
12470 case ssoCURRENTITEMCLASSTEXT:
12471 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12472
12473 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12474 custom_subscreen[2].objects[i].dp1 = NULL;
12475 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12476 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12477 break;
12478
12479 case ssoLIFEMETER:
12480 {
12481 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12482
12483 if(get_bit(deprecated_rules, 12) != 0)
12484 custom_subscreen[2].objects[i].d3=1;
12485 else
12486 custom_subscreen[2].objects[i].d3=0;
12487
12488 break;
12489 }
12490
12491 default:
12492 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12493 break;
12494 }
12495 }
12496
12497 custom_subscreen[2].ss_type=sstPASSIVE;
12498 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12499 tempsub = z3_passive_ab;
12500
12501 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12502 {
12503 switch(tempsub[i].type)
12504 {
12505 case ssoTEXT:
12506 case ssoTEXTBOX:
12507 case ssoCURRENTITEMTEXT:
12508 case ssoCURRENTITEMCLASSTEXT:
12509 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12510
12511 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12512 custom_subscreen[3].objects[i].dp1 = NULL;
12513 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12514 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12515 break;
12516
12517 case ssoLIFEMETER:
12518 {
12519 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12520
12521 if(get_bit(deprecated_rules, 12) != 0)
12522 custom_subscreen[3].objects[i].d3=1;
12523 else
12524 custom_subscreen[3].objects[i].d3=0;
12525
12526 break;
12527 }
12528
12529 default:
12530 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12531 break;
12532 }
12533 }
12534
12535 custom_subscreen[3].ss_type=sstPASSIVE;
12536 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12537 break;
12538 }
12539 }
12540
12541
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 92 times.
115 for(int32_t i=0; i<4; ++i)
12542 {
12543 92 purge_blank_subscreen_objects(&custom_subscreen[i]);
12544 92 }
12545
12546 23 return 0;
12547 }
12548
12549 extern script_data *ffscripts[NUMSCRIPTFFC];
12550 extern script_data *itemscripts[NUMSCRIPTITEM];
12551 extern script_data *guyscripts[NUMSCRIPTGUYS];
12552 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12553 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12554 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12555 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12556 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12557 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12558 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12559 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12560 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12561 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12562 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12563
12564
12565
12566 106 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12567 {
12568 int32_t dummy;
12569 106 word s_version=0, s_cversion=0, zmeta_version=0;
12570 106 byte numscripts=0;
12571 106 numscripts=numscripts; //to avoid unused variables warnings
12572 int32_t ret;
12573
12574 //section version info
12575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
12576 {
12577 return qe_invalid;
12578 }
12579
12580 106 FFCore.quest_format[vFFScript] = s_version;
12581
12582
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
12583 {
12584 return qe_invalid;
12585 }
12586
12587
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >= 18)
12588 {
12589
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&zmeta_version,f,true))
12590 {
12591 return qe_invalid;
12592 }
12593 30 }
12594
12595 //al_trace("Scripts version %d\n", s_version);
12596 //section size
12597
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy,f,true))
12598 {
12599 return qe_invalid;
12600 }
12601
12602 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12603 106 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12604 106 temp_ffscript_version = s_version;
12605 //miscQdata *the_misc;
12606
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12607 106 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12608
12609 //finally... section data
12610
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 106 times.
54378 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12611 {
12612 54272 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12613
12614
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(ret != 0) return qe_invalid;
12615 54272 }
12616
12617 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12618 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12619 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12620 * there was a version bump a week before a change that broke stuff.
12621 */
12622
6/8
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 76 times.
106 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12623 {
12624 76 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12625 76 }
12626
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
106 if(s_version < 19 && keepdata)
12627 {
12628 76 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12629 76 }
12630
12631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version > 1)
12632 {
12633
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12634 {
12635 27136 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12636
12637
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(ret != 0) return qe_invalid;
12638 27136 }
12639
12640
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12641 {
12642 27136 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12643
12644
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(ret != 0) return qe_invalid;
12645 27136 }
12646
12647
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12648 {
12649 27136 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12650
12651
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(ret != 0) return qe_invalid;
12652 27136 }
12653
12654
12655
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12656 {
12657 27136 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12658
12659
1/2
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
27136 if(ret != 0) return qe_invalid;
12660 27136 }
12661
12662
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if(s_version > 16)
12663 {
12664
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 30 times.
270 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12665 {
12666 240 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12667
12668
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(ret != 0) return qe_invalid;
12669 240 }
12670 30 }
12671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 else if(s_version > 13)
12672 {
12673 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12674 {
12675 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12676
12677 if(ret != 0) return qe_invalid;
12678 }
12679
12680 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12681 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12682
12683 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12684 }
12685
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 else if(s_version > 4)
12686 {
12687
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12688 {
12689 304 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12690
12691
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(ret != 0) return qe_invalid;
12692 304 }
12693
12694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12695
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12696
12697
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12698
12699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12700
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12701
12702
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12703
12704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12705
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_F6];
12706
12707
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12708
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12710
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12711
12712
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12713 76 }
12714 else
12715 {
12716 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12717 {
12718 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12719
12720 if(ret != 0) return qe_invalid;
12721 }
12722
12723 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12724 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12725
12726 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12727
12728 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12729 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12730
12731 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12732
12733 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12734 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12735
12736 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12737
12738 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12739 delete globalscripts[GLOBAL_SCRIPT_F6];
12740
12741 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12742
12743 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12744 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12745
12746 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12747 }
12748
12749
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if(s_version > 10) //expanded the number of Player scripts to 5.
12750 {
12751
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 30 times.
180 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12752 {
12753 150 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12754
12755
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(ret != 0) return qe_invalid;
12756 150 }
12757 30 }
12758 else
12759 {
12760
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 76 times.
304 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12761 {
12762 228 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12763
12764
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(ret != 0) return qe_invalid;
12765 228 }
12766
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[3] != NULL)
12767
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete playerscripts[3];
12768
12769
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[3] = new script_data();
12770
12771
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[4] != NULL)
12772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 delete playerscripts[4];
12773
12774
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[4] = new script_data();
12775 }
12776
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
106 if(s_version > 8 && s_version < 10)
12777 {
12778
12779 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12780 {
12781 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12782
12783 if(ret != 0) return qe_invalid;
12784 }
12785 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12786 {
12787 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12788
12789 if(ret != 0) return qe_invalid;
12790 }
12791
12792 }
12793
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >= 10)
12794 {
12795
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12796 {
12797 7680 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12798
12799
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(ret != 0) return qe_invalid;
12800 7680 }
12801
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12802 {
12803 7680 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12804
12805
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(ret != 0) return qe_invalid;
12806 7680 }
12807
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12808 {
12809 7680 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12810
12811
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(ret != 0) return qe_invalid;
12812 7680 }
12813
12814 30 }
12815
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >=12)
12816 {
12817
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 30 times.
7710 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12818 {
12819 7680 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12820
12821
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(ret != 0) return qe_invalid;
12822 7680 }
12823 30 }
12824
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >=15)
12825 {
12826
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 30 times.
15390 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12827 {
12828 15360 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12829
12830
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(ret != 0) return qe_invalid;
12831 15360 }
12832 30 }
12833
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >19)
12834 {
12835 30 word numgenscripts = NUMSCRIPTSGENERIC;
12836
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetw(&numgenscripts,f,true))
12837 {
12838 return qe_invalid;
12839 }
12840
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 30 times.
15390 for(int32_t i = 0; i < numgenscripts; i++)
12841 {
12842 15360 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12843
12844
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(ret != 0) return qe_invalid;
12845 15360 }
12846 30 }
12847
12848 /*
12849 else //Is this trip really necessary?
12850 {
12851 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12852 {
12853
12854 ewpnscripts[i] = NULL;
12855 }
12856 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12857 {
12858 dmapscripts[i] = NULL;
12859 }
12860 }
12861 */
12862
12863 106 }
12864
12865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version > 2)
12866 {
12867 int32_t bufsize;
12868 106 p_igetl(&bufsize, f, true);
12869
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
106 if (bufsize < 0 || bufsize > 1024*1024*10)
12870 {
12871 // God help anyone storing more than 10MB of code in the script buffer.
12872 return qe_invalid;
12873 }
12874 106 char * buf = new char[bufsize+1];
12875 106 pfread(buf, bufsize, f, true);
12876 106 buf[bufsize]=0;
12877
12878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata)
12879
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 zScript = string(buf);
12880
12881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 delete[] buf;
12882 word numffcbindings;
12883 106 p_igetw(&numffcbindings, f, true);
12884
12885
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 106 times.
1628 for(int32_t i=0; i<numffcbindings; i++)
12886 {
12887 word id;
12888 1522 p_igetw(&id, f, true);
12889 1522 p_igetl(&bufsize, f, true);
12890
2/4
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1522 times.
1522 if (bufsize < 0 || bufsize > 1024)
12891 return qe_invalid;
12892 1522 buf = new char[bufsize+1];
12893 1522 pfread(buf, bufsize, f, true);
12894 1522 buf[bufsize]=0;
12895
12896 //fix for buggy older saved quests -DD
12897
2/4
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1522 times.
1522 if(keepdata && id < NUMSCRIPTFFC-1)
12898 1522 ffcmap[id].scriptname = buf;
12899
12900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1522 times.
1522 delete[] buf;
12901 1522 }
12902
12903 word numglobalbindings;
12904 106 p_igetw(&numglobalbindings, f, true);
12905
12906
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 106 times.
529 for(int32_t i=0; i<numglobalbindings; i++)
12907 {
12908 word id;
12909 423 p_igetw(&id, f, true);
12910 423 p_igetl(&bufsize, f, true);
12911
2/4
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
423 if (bufsize < 0 || bufsize > 1024)
12912 return qe_invalid;
12913 423 buf = new char[bufsize+1];
12914 423 pfread(buf, bufsize, f, true);
12915 423 buf[bufsize]=0;
12916
12917 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12918 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12919 // Ignore these. -DD
12920
4/6
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 264 times.
423 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12921 {
12922 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(strcmp(buf,"~Continue") == 0)
12924 {
12925 globalmap[id].scriptname = "";
12926
12927 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12928 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12929 }
12930 else
12931 {
12932 264 globalmap[id].scriptname = buf;
12933 }
12934 264 }
12935
12936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 delete[] buf;
12937 423 }
12938
12939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version > 3)
12940 {
12941 word numitembindings;
12942 106 p_igetw(&numitembindings, f, true);
12943
12944
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 106 times.
204 for(int32_t i=0; i<numitembindings; i++)
12945 {
12946 word id;
12947 98 p_igetw(&id, f, true);
12948 98 p_igetl(&bufsize, f, true);
12949
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
98 if (bufsize < 0 || bufsize > 1024)
12950 return qe_invalid;
12951 98 buf = new char[bufsize+1];
12952 98 pfread(buf, bufsize, f, true);
12953 98 buf[bufsize]=0;
12954
12955 //fix this too
12956
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if(keepdata && id <NUMSCRIPTITEM-1)
12957 98 itemmap[id].scriptname = buf;
12958
12959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12960 98 }
12961 106 }
12962 //(v9+)
12963
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version > 8)
12964 {
12965 //npc scripts
12966 word numnpcbindings;
12967 30 p_igetw(&numnpcbindings, f, true);
12968
12969
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 30 times.
42 for(int32_t i=0; i<numnpcbindings; i++)
12970 {
12971 word id;
12972 12 p_igetw(&id, f, true);
12973 12 p_igetl(&bufsize, f, true);
12974
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (bufsize < 0 || bufsize > 1024)
12975 return qe_invalid;
12976 12 buf = new char[bufsize+1];
12977 12 pfread(buf, bufsize, f, true);
12978 12 buf[bufsize]=0;
12979
12980 //fix this too
12981
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12982 12 npcmap[id].scriptname = buf;
12983
12984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12985 12 }
12986 //lweapon
12987 word numlwpnbindings;
12988 30 p_igetw(&numlwpnbindings, f, true);
12989
12990
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 for(int32_t i=0; i<numlwpnbindings; i++)
12991 {
12992 word id;
12993 42 p_igetw(&id, f, true);
12994 42 p_igetl(&bufsize, f, true);
12995
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
42 if (bufsize < 0 || bufsize > 1024)
12996 return qe_invalid;
12997 42 buf = new char[bufsize+1];
12998 42 pfread(buf, bufsize, f, true);
12999 42 buf[bufsize]=0;
13000
13001 //fix this too
13002
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
13003 42 lwpnmap[id].scriptname = buf;
13004
13005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
13006 42 }
13007 //eweapon
13008 word numewpnbindings;
13009 30 p_igetw(&numewpnbindings, f, true);
13010
13011
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 30 times.
93 for(int32_t i=0; i<numewpnbindings; i++)
13012 {
13013 word id;
13014 63 p_igetw(&id, f, true);
13015 63 p_igetl(&bufsize, f, true);
13016
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
13017 return qe_invalid;
13018 63 buf = new char[bufsize+1];
13019 63 pfread(buf, bufsize, f, true);
13020 63 buf[bufsize]=0;
13021
13022 //fix this too
13023
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
13024 63 ewpnmap[id].scriptname = buf;
13025
13026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
13027 63 }
13028 //hero
13029 word numherobindings;
13030 30 p_igetw(&numherobindings, f, true);
13031
13032
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 30 times.
35 for(int32_t i=0; i<numherobindings; i++)
13033 {
13034 word id;
13035 5 p_igetw(&id, f, true);
13036 5 p_igetl(&bufsize, f, true);
13037
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
13038 return qe_invalid;
13039 5 buf = new char[bufsize+1];
13040 5 pfread(buf, bufsize, f, true);
13041 5 buf[bufsize]=0;
13042
13043 //fix this too
13044
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(keepdata && id <NUMSCRIPTPLAYER-1)
13045 5 playermap[id].scriptname = buf;
13046
13047
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 delete[] buf;
13048 5 }
13049 //dmaps
13050 word numdmapbindings;
13051 30 p_igetw(&numdmapbindings, f, true);
13052
13053
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 30 times.
57 for(int32_t i=0; i<numdmapbindings; i++)
13054 {
13055 word id;
13056 27 p_igetw(&id, f, true);
13057 27 p_igetl(&bufsize, f, true);
13058
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
27 if (bufsize < 0 || bufsize > 1024)
13059 return qe_invalid;
13060 27 buf = new char[bufsize+1];
13061 27 pfread(buf, bufsize, f, true);
13062 27 buf[bufsize]=0;
13063
13064 //fix this too
13065
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
27 if(keepdata && id <NUMSCRIPTSDMAP-1)
13066 27 dmapmap[id].scriptname = buf;
13067
13068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 delete[] buf;
13069 27 }
13070 //screen
13071 word numscreenbindings;
13072 30 p_igetw(&numscreenbindings, f, true);
13073
13074
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 30 times.
48 for(int32_t i=0; i<numscreenbindings; i++)
13075 {
13076 word id;
13077 18 p_igetw(&id, f, true);
13078 18 p_igetl(&bufsize, f, true);
13079
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if (bufsize < 0 || bufsize > 1024)
13080 return qe_invalid;
13081 18 buf = new char[bufsize+1];
13082 18 pfread(buf, bufsize, f, true);
13083 18 buf[bufsize]=0;
13084
13085 //fix this too
13086
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(keepdata && id <NUMSCRIPTSDMAP-1)
13087 18 screenmap[id].scriptname = buf;
13088
13089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
13090 18 }
13091 30 }
13092
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version > 11)
13093 {
13094 word numspritebindings;
13095 30 p_igetw(&numspritebindings, f, true);
13096
13097
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 30 times.
40 for(int32_t i=0; i<numspritebindings; i++)
13098 {
13099 word id;
13100 10 p_igetw(&id, f, true);
13101 10 p_igetl(&bufsize, f, true);
13102
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if (bufsize < 0 || bufsize > 1024)
13103 return qe_invalid;
13104 10 buf = new char[bufsize+1];
13105 10 pfread(buf, bufsize, f, true);
13106 10 buf[bufsize]=0;
13107
13108 //fix this too
13109
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
13110 10 itemspritemap[id].scriptname = buf;
13111
13112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
13113 10 }
13114 30 }
13115
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version >= 15)
13116 {
13117 word numcombobindings;
13118 30 p_igetw(&numcombobindings, f, true);
13119
13120
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 30 times.
53 for(int32_t i=0; i<numcombobindings; i++)
13121 {
13122 word id;
13123 23 p_igetw(&id, f, true);
13124 23 p_igetl(&bufsize, f, true);
13125
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
13126 return qe_invalid;
13127 23 buf = new char[bufsize+1];
13128 23 pfread(buf, bufsize, f, true);
13129 23 buf[bufsize]=0;
13130
13131 //fix this too
13132
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
13133 23 comboscriptmap[id].scriptname = buf;
13134
13135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
13136 23 }
13137 30 }
13138
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 30 times.
106 if(s_version > 19)
13139 {
13140 word numgenericbindings;
13141 30 p_igetw(&numgenericbindings, f, true);
13142
13143
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 30 times.
43 for(int32_t i=0; i<numgenericbindings; i++)
13144 {
13145 word id;
13146 13 p_igetw(&id, f, true);
13147 13 p_igetl(&bufsize, f, true);
13148
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
13149 return qe_invalid;
13150 13 buf = new char[bufsize+1];
13151 13 pfread(buf, bufsize, f, true);
13152 13 buf[bufsize]=0;
13153
13154 //fix this too
13155
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13156 13 genericmap[id].scriptname = buf;
13157
13158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
13159 13 }
13160 30 }
13161 106 }
13162
13163 106 return 0;
13164 106 }
13165
13166 115 void reset_scripts()
13167 {
13168 //OK, who spaced this? ;)
13169
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13170 {
13171
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58880 times.
58880 if(ffscripts[i]!=NULL) delete ffscripts[i];
13172 58880 }
13173
13174
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13175 {
13176
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(itemscripts[i]!=NULL) delete itemscripts[i];
13177 29440 }
13178
13179
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13180 {
13181
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(guyscripts[i]!=NULL) delete guyscripts[i];
13182 29440 }
13183
13184
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13185 {
13186
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13187 29440 }
13188
13189
13190
13191
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13192 {
13193
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(screenscripts[i]!=NULL) delete screenscripts[i];
13194 29440 }
13195
13196
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 115 times.
1035 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13197 {
13198
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 920 times.
920 if(globalscripts[i]!=NULL) delete globalscripts[i];
13199 920 }
13200
13201
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 115 times.
690 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13202 {
13203
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
575 if(playerscripts[i]!=NULL) delete playerscripts[i];
13204 575 }
13205
13206
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13207 {
13208
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13209 29440 }
13210
13211
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13212 {
13213
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13214 29440 }
13215
13216
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13217 {
13218
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13219 29440 }
13220
13221
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13222 {
13223
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29440 times.
29440 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13224 29440 }
13225
13226
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13227 {
13228
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58880 times.
58880 if(comboscripts[i]!=NULL) delete comboscripts[i];
13229 58880 }
13230
13231 115 next_script_data_debug_id = 0;
13232
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13233 {
13234
3/4
✓ Branch 0 taken 19968 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 38912 times.
✗ Branch 3 not taken.
58880 if(genericscripts[i]!=NULL) delete genericscripts[i];
13235
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 genericscripts[i] = new script_data();
13236 58880 }
13237
13238
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13239 {
13240
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 ffscripts[i] = new script_data();
13241 58880 }
13242
13243
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13244 {
13245
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 itemscripts[i] = new script_data();
13246 29440 }
13247
13248
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13249 {
13250
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 guyscripts[i] = new script_data();
13251 29440 }
13252
13253
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13254 {
13255
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 wpnscripts[i] = new script_data();
13256 29440 }
13257
13258
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13259 {
13260
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 screenscripts[i] = new script_data();
13261 29440 }
13262
13263
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 115 times.
1035 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13264 {
13265
1/2
✓ Branch 0 taken 920 times.
✗ Branch 1 not taken.
920 globalscripts[i] = new script_data();
13266 920 }
13267
13268
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 115 times.
690 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13269 {
13270
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 playerscripts[i] = new script_data();
13271 575 }
13272
13273
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13274 {
13275
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 lwpnscripts[i] = new script_data();
13276 29440 }
13277
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13278 {
13279
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 ewpnscripts[i] = new script_data();
13280 29440 }
13281
13282
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13283 {
13284
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 dmapscripts[i] = new script_data();
13285 29440 }
13286
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13287 {
13288
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 itemspritescripts[i] = new script_data();
13289 29440 }
13290
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13291 {
13292
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 comboscripts[i] = new script_data();
13293 58880 }
13294 115 }
13295
13296 extern script_command command_list[];
13297 225178 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13298 {
13299 //Please also update loadquest() when modifying this method -DD
13300 225178 char b33[34] = {0};
13301 225178 b33[33] = 0;
13302 225178 ffscript temp_script;
13303 225178 int32_t num_commands=1000;
13304
13305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225178 times.
225178 if(s_version>=2)
13306 {
13307
2/4
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225178 times.
✗ Branch 3 not taken.
225178 if(!p_igetl(&num_commands,f,true))
13308 {
13309 return qe_invalid;
13310 }
13311 225178 }
13312
13313 #ifdef ZC_FUZZ
13314 const int32_t command_limit = 300000;
13315 #else
13316 225178 const int32_t command_limit = 10000000;
13317 #endif
13318
2/4
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225178 times.
✗ Branch 3 not taken.
225178 if (num_commands < 0 || num_commands > command_limit)
13319 {
13320 return qe_invalid;
13321 }
13322
13323
1/2
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
225178 if(keepdata)
13324 {
13325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225178 times.
225178 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225178 times.
225178 delete (*script);
13327
2/4
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225178 times.
✗ Branch 3 not taken.
225178 (*script) = new script_data(num_commands);
13328 225178 }
13329
2/2
✓ Branch 0 taken 107910 times.
✓ Branch 1 taken 117268 times.
225178 if(s_version >= 16)
13330 {
13331
1/2
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
107910 zasm_meta temp_meta;
13332
13333
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13334 {
13335 return qe_invalid;
13336 }
13337
13338
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.meta_v),f,true))
13339 {
13340 return qe_invalid;
13341 }
13342
13343
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13344 {
13345 return qe_invalid;
13346 }
13347
13348
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_getc(&(temp_meta.script_type),f,true))
13349 {
13350 return qe_invalid;
13351 }
13352
13353
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 107910 times.
971190 for(int32_t q = 0; q < 8; ++q)
13354 {
13355
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 805728 times.
863280 if(zmeta_version < 3)
13356 {
13357
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13358 {
13359
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13360 {
13361 return qe_invalid;
13362 }
13363 1899216 }
13364
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13365 57552 }
13366 else
13367 {
13368
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13369 {
13370 return qe_invalid;
13371 }
13372 }
13373 863280 }
13374
13375
2/2
✓ Branch 0 taken 107910 times.
✓ Branch 1 taken 863280 times.
971190 for(int32_t q = 0; q < 8; ++q)
13376 {
13377
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13378 {
13379 return qe_invalid;
13380 }
13381 863280 }
13382
13383
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_getc(&(temp_meta.flags),f,true))
13384 {
13385 return qe_invalid;
13386 }
13387
13388
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13389 {
13390 return qe_invalid;
13391 }
13392
13393
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13394 {
13395 return qe_invalid;
13396 }
13397
13398
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13399 {
13400 return qe_invalid;
13401 }
13402
13403
2/4
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107910 times.
✗ Branch 3 not taken.
107910 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13404 {
13405 return qe_invalid;
13406 }
13407
13408
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 100716 times.
107910 if(zmeta_version == 2)
13409 {
13410
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13411 {
13412
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13413 {
13414 return qe_invalid;
13415 }
13416 237402 }
13417
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13418
13419
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13420 {
13421
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13422 {
13423 return qe_invalid;
13424 }
13425 237402 }
13426
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13427 7194 }
13428
1/2
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
100716 else if(zmeta_version > 2)
13429 {
13430
2/4
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100716 times.
✗ Branch 3 not taken.
100716 if(!p_getcstr(&temp_meta.script_name,f,true))
13431 return qe_invalid;
13432
2/4
✓ Branch 0 taken 100716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100716 times.
✗ Branch 3 not taken.
100716 if(!p_getcstr(&temp_meta.author,f,true))
13433 return qe_invalid;
13434 100716 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13435
2/2
✓ Branch 0 taken 1007160 times.
✓ Branch 1 taken 100716 times.
1107876 for(auto q = 0; q < num_meta_attrib; ++q)
13436 {
13437
2/4
✓ Branch 0 taken 1007160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1007160 times.
✗ Branch 3 not taken.
1007160 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13438 return qe_invalid;
13439
2/4
✓ Branch 0 taken 1007160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1007160 times.
✗ Branch 3 not taken.
1007160 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13440 return qe_invalid;
13441 1007160 }
13442
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13443 {
13444
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13445 return qe_invalid;
13446
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13447 return qe_invalid;
13448 805728 }
13449
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13450 {
13451
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13452 return qe_invalid;
13453
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13454 return qe_invalid;
13455 805728 }
13456
2/2
✓ Branch 0 taken 1611456 times.
✓ Branch 1 taken 100716 times.
1712172 for(auto q = 0; q < 16; ++q)
13457 {
13458
2/4
✓ Branch 0 taken 1611456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1611456 times.
✗ Branch 3 not taken.
1611456 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13459 return qe_invalid;
13460
2/4
✓ Branch 0 taken 1611456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1611456 times.
✗ Branch 3 not taken.
1611456 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13461 return qe_invalid;
13462 1611456 }
13463 100716 }
13464
2/2
✓ Branch 0 taken 100716 times.
✓ Branch 1 taken 7194 times.
107910 if(zmeta_version > 3)
13465 {
13466
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13467 {
13468
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getcstr(&temp_meta.initd[q],f,true))
13469 return qe_invalid;
13470
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13471 return qe_invalid;
13472 805728 }
13473
2/2
✓ Branch 0 taken 805728 times.
✓ Branch 1 taken 100716 times.
906444 for(auto q = 0; q < 8; ++q)
13474 {
13475
2/4
✓ Branch 0 taken 805728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805728 times.
✗ Branch 3 not taken.
805728 if(!p_getc(&temp_meta.initd_type[q],f,true))
13476 return qe_invalid;
13477 805728 }
13478 100716 }
13479 else
13480 {
13481
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13482 {
13483
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13484 57552 }
13485 }
13486
13487
1/2
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
107910 if(keepdata)
13488
1/2
✓ Branch 0 taken 107910 times.
✗ Branch 1 not taken.
107910 (*script)->meta = temp_meta;
13489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107910 times.
107910 }
13490
13491
1/2
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
225178 temp_script.clear();
13492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21687943 times.
21687943 for(int32_t j=0; j<num_commands; j++)
13493 {
13494
2/4
✓ Branch 0 taken 21687943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21687943 times.
✗ Branch 3 not taken.
21687943 if(!p_igetw(&(temp_script.command),f,true))
13495 {
13496 return qe_invalid;
13497 }
13498
13499
2/2
✓ Branch 0 taken 21462765 times.
✓ Branch 1 taken 225178 times.
21687943 if(temp_script.command == 0xFFFF)
13500 {
13501
1/2
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
225178 if(keepdata)
13502
1/2
✓ Branch 0 taken 225178 times.
✗ Branch 1 not taken.
225178 (*script)->zasm[j].clear();
13503 225178 break;
13504 }
13505 else
13506 {
13507
2/4
✓ Branch 0 taken 21462765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21462765 times.
✗ Branch 3 not taken.
21462765 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13508 {
13509 return qe_invalid;
13510 }
13511
13512
2/4
✓ Branch 0 taken 21462765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21462765 times.
✗ Branch 3 not taken.
21462765 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13513 {
13514 return qe_invalid;
13515 }
13516
13517
2/2
✓ Branch 0 taken 790970 times.
✓ Branch 1 taken 20671795 times.
21462765 if(s_version >= 21)
13518 {
13519 790970 uint32_t sz = 0;
13520
2/4
✓ Branch 0 taken 790970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 790970 times.
✗ Branch 3 not taken.
790970 if(!p_igetl(&sz,f,keepdata))
13521 {
13522 return qe_invalid;
13523 }
13524
2/2
✓ Branch 0 taken 2935 times.
✓ Branch 1 taken 788035 times.
790970 if(sz) //string found
13525 {
13526
1/2
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
2935 temp_script.strptr = new std::string();
13527 char dummy;
13528
2/2
✓ Branch 0 taken 227913 times.
✓ Branch 1 taken 2935 times.
230848 for(size_t q = 0; q < sz; ++q)
13529 {
13530
2/4
✓ Branch 0 taken 227913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227913 times.
✗ Branch 3 not taken.
227913 if(!p_getc(&dummy,f,keepdata))
13531 {
13532 return qe_invalid;
13533 }
13534
1/2
✓ Branch 0 taken 227913 times.
✗ Branch 1 not taken.
227913 temp_script.strptr->push_back(dummy);
13535 227913 }
13536 2935 }
13537
2/4
✓ Branch 0 taken 790970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 790970 times.
✗ Branch 3 not taken.
790970 if(!p_igetl(&sz,f,keepdata))
13538 {
13539 return qe_invalid;
13540 }
13541
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 790869 times.
790970 if(sz) //vector found
13542 {
13543
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13544 int32_t dummy;
13545
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13546 {
13547
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f,keepdata))
13548 {
13549 return qe_invalid;
13550 }
13551
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13552 1487 }
13553 101 }
13554 790970 }
13555
13556
1/2
✓ Branch 0 taken 21462765 times.
✗ Branch 1 not taken.
21462765 if(keepdata)
13557 {
13558
1/2
✓ Branch 0 taken 21462765 times.
✗ Branch 1 not taken.
21462765 temp_script.give((*script)->zasm[j]);
13559 21462765 }
13560 }
13561
1/2
✓ Branch 0 taken 21462765 times.
✗ Branch 1 not taken.
21462765 temp_script.clear();
13562 21462765 }
13563
13564 225178 return 0;
13565 225178 }
13566
13567 extern SAMPLE customsfxdata[WAV_COUNT];
13568 extern uint8_t customsfxflag[WAV_COUNT>>3];
13569 extern int32_t sfxdat;
13570 extern DATAFILE *sfxdata;
13571 const char *old_sfx_string[Z35] =
13572 {
13573 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13574 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13575 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13576 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13577 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13578 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13579 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13580 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13581 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13582 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13583 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13584 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13585 };
13586 char *sfx_string[WAV_COUNT];
13587
13588 106 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13589 {
13590 //these are here to bypass compiler warnings about unused arguments
13591 106 Header=Header;
13592
13593 int32_t dummy;
13594 106 word s_version=0, s_cversion=0;
13595 //int32_t ret;
13596 SAMPLE temp_sample;
13597 106 temp_sample.loop_start=0;
13598 106 temp_sample.loop_end=0;
13599 106 temp_sample.param=0;
13600
13601 //section version info
13602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
13603 {
13604 return qe_invalid;
13605 }
13606
13607 106 FFCore.quest_format[vSFX] = s_version;
13608
13609 //al_trace("SFX version %d\n", s_version);
13610
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
13611 {
13612 return qe_invalid;
13613 }
13614
13615 //section size
13616
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy,f,true))
13617 {
13618 return qe_invalid;
13619 }
13620
13621 /* HIGHLY UNORTHODOX UPDATING THING, by L
13622 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13623 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13624 * changing from 1 to 2.
13625 */
13626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
106 if(s_version < 2 && keepdata)
13627 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13628
13629 /* End highly unorthodox updating thing */
13630
13631 106 int32_t wavcount = WAV_COUNT;
13632
13633
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(s_version < 6)
13634 wavcount = 128;
13635
13636 uint8_t tempflag[WAV_COUNT>>3];
13637
13638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version < 4)
13639 {
13640 memset(tempflag, 0xFF, WAV_COUNT>>3);
13641 }
13642 else
13643 {
13644
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(s_version < 6)
13645 memset(tempflag, 0, WAV_COUNT>>3);
13646
13647
2/2
✓ Branch 0 taken 3392 times.
✓ Branch 1 taken 106 times.
3498 for(int32_t i=0; i<(wavcount>>3); i++)
13648 {
13649 3392 p_getc(&tempflag[i], f, true);
13650 3392 }
13651
13652 }
13653
13654
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(s_version>4)
13655 {
13656
2/2
✓ Branch 0 taken 27030 times.
✓ Branch 1 taken 106 times.
27136 for(int32_t i=1; i<WAV_COUNT; i++)
13657 {
13658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27030 times.
27030 if(keepdata)
13659 {
13660 27030 sprintf(sfx_string[i],"s%03d",i);
13661
13662
2/2
✓ Branch 0 taken 20670 times.
✓ Branch 1 taken 6360 times.
27030 if((i<Z35))
13663 6360 strcpy(sfx_string[i], old_sfx_string[i-1]);
13664 27030 }
13665
13666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27030 times.
27030 if(i>=wavcount)
13667 continue;
13668
2/2
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 24448 times.
27030 if(get_bit(tempflag, i-1))
13669 {
13670 char tempname[36];
13671
13672
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!pfread(tempname, 36, f, keepdata))
13673 {
13674 return qe_invalid;
13675 }
13676
13677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2582 times.
2582 if(keepdata)
13678 {
13679 2582 sfx_string[i][0] = '\0';
13680 2582 strncat(sfx_string[i], tempname, 36 - 1);
13681 2582 }
13682 2582 }
13683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24448 times.
24448 else if(keepdata)
13684 {
13685 24448 sprintf(sfx_string[i],"s%03d",i);
13686
13687
2/2
✓ Branch 0 taken 19930 times.
✓ Branch 1 taken 4518 times.
24448 if(i<Z35)
13688 4518 strcpy(sfx_string[i], old_sfx_string[i-1]);
13689 24448 sfx_string[i][35] = 0; //Force NULL Termination
13690 24448 }
13691 27030 }
13692 106 }
13693 else
13694 {
13695 if(keepdata)
13696 {
13697 for(int32_t i=1; i<WAV_COUNT; i++)
13698 {
13699 sprintf(sfx_string[i],"s%03d",i);
13700
13701 if(i<Z35)
13702 strcpy(sfx_string[i], old_sfx_string[i-1]);
13703 }
13704 }
13705 }
13706
13707 //finally... section data
13708
2/2
✓ Branch 0 taken 27030 times.
✓ Branch 1 taken 106 times.
27136 for(int32_t i=1; i<wavcount; i++)
13709 {
13710
2/2
✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 24448 times.
27030 if(get_bit(tempflag, i-1))
13711 {
13712
13713
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f,true))
13714 {
13715 return qe_invalid;
13716 }
13717
13718 2582 (temp_sample.bits) = dummy;
13719
13720
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f,true))
13721 {
13722 return qe_invalid;
13723 }
13724
13725 2582 (temp_sample.stereo) = dummy;
13726
13727
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f,keepdata))
13728 {
13729 return qe_invalid;
13730 }
13731
13732 2582 (temp_sample.freq) = dummy;
13733
13734
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&dummy,f,keepdata))
13735 {
13736 return qe_invalid;
13737 }
13738
13739 2582 (temp_sample.priority) = dummy;
13740
13741
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.len),f,true))
13742 {
13743 return qe_invalid;
13744 }
13745
13746
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13747 {
13748 return qe_invalid;
13749 }
13750
13751
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13752 {
13753 return qe_invalid;
13754 }
13755
13756
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(!p_igetl(&(temp_sample.param),f,keepdata))
13757 {
13758 return qe_invalid;
13759 }
13760
13761 // al_trace("F%i: L%i\n",i,temp_sample.len);
13762 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13763 2582 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13764
2/4
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2582 times.
2582 if (len < 0 || len > 10000000)
13765 {
13766 return qe_invalid;
13767 }
13768 2582 temp_sample.data = calloc(len,1);
13769
13770
1/2
✓ Branch 0 taken 2582 times.
✗ Branch 1 not taken.
2582 if(s_version < 3)
13771 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13772
13773 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2582 times.
2582 if(s_version < 2)
13775 {
13776 if(!pfread(temp_sample.data, len,f,keepdata))
13777 {
13778 return qe_invalid;
13779 }
13780 }
13781 else
13782 {
13783 //re-endianfy the data
13784 2582 int32_t wordstoread = len / sizeof(word);
13785
13786
2/2
✓ Branch 0 taken 77959645 times.
✓ Branch 1 taken 2582 times.
77962227 for(int32_t j=0; j<wordstoread; j++)
13787 {
13788 word temp;
13789
13790
1/2
✓ Branch 0 taken 77959645 times.
✗ Branch 1 not taken.
77959645 if(!p_igetw(&temp, f, keepdata))
13791 {
13792 return qe_invalid;
13793 }
13794
13795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77959645 times.
77959645 if(keepdata)
13796 77959645 ((word *)temp_sample.data)[j] = temp;
13797 77959645 }
13798 }
13799 2582 }
13800
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 19930 times.
24448 else if(i < Z35)
13801 {
13802 4518 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13803 4518 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13804 4518 set_bit(tempflag, i-1, 1);
13805 4518 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13806 4518 temp_sample.data = calloc(len,1);
13807 4518 memcpy(temp_sample.data, datsamp->data, len);
13808 4518 }
13809 19930 else continue;
13810
13811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7100 times.
7100 if(keepdata)
13812 {
13813
1/2
✓ Branch 0 taken 7100 times.
✗ Branch 1 not taken.
7100 if(customsfxdata[i].data!=NULL)
13814 {
13815 // delete [] customsfxdata[i].data;
13816 7100 free(customsfxdata[i].data);
13817 7100 }
13818
13819 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13820 7100 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13821 7100 customsfxdata[i].data = calloc(len2,1);
13822 7100 customsfxdata[i].bits = temp_sample.bits;
13823 7100 customsfxdata[i].stereo = temp_sample.stereo;
13824 7100 customsfxdata[i].freq = temp_sample.freq;
13825 7100 customsfxdata[i].priority = temp_sample.priority;
13826 7100 customsfxdata[i].len = temp_sample.len;
13827 7100 customsfxdata[i].loop_start = temp_sample.loop_start;
13828 7100 customsfxdata[i].loop_end = temp_sample.loop_end;
13829 7100 customsfxdata[i].param = temp_sample.param;
13830 7100 int32_t cpylen = len2;
13831
13832
1/2
✓ Branch 0 taken 7100 times.
✗ Branch 1 not taken.
7100 if(s_version<3)
13833 {
13834 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13835 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13836 }
13837
13838 7100 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13839 7100 }
13840
13841 7100 free(temp_sample.data);
13842 7100 }
13843
13844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata)
13845 106 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13846
13847 106 sfxdat=0;
13848 106 return 0;
13849 106 }
13850
13851 115 void setupsfx()
13852 {
13853
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=1; i<WAV_COUNT; i++)
13854 {
13855 29325 sprintf(sfx_string[i],"s%03d",i);
13856
13857
2/2
✓ Branch 0 taken 22425 times.
✓ Branch 1 taken 6900 times.
29325 if(i<Z35)
13858 {
13859 6900 strcpy(sfx_string[i], old_sfx_string[i-1]);
13860 6900 }
13861
13862 29325 memset(customsfxflag, 0, WAV_COUNT>>3);
13863
13864 29325 int32_t j=i;
13865
13866
2/2
✓ Branch 0 taken 7015 times.
✓ Branch 1 taken 22310 times.
29325 if(i>Z35)
13867 {
13868 22310 i=Z35;
13869 22310 }
13870
13871 29325 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13872
13873
2/2
✓ Branch 0 taken 9945 times.
✓ Branch 1 taken 19380 times.
29325 if(customsfxdata[j].data!=NULL)
13874 {
13875 // delete [] customsfxdata[j].data;
13876 19380 free(customsfxdata[j].data);
13877 19380 }
13878
13879 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13880 29325 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13881 29325 customsfxdata[j].bits = temp_sample->bits;
13882 29325 customsfxdata[j].stereo = temp_sample->stereo;
13883 29325 customsfxdata[j].freq = temp_sample->freq;
13884 29325 customsfxdata[j].priority = temp_sample->priority;
13885 29325 customsfxdata[j].len = temp_sample->len;
13886 29325 customsfxdata[j].loop_start = temp_sample->loop_start;
13887 29325 customsfxdata[j].loop_end = temp_sample->loop_end;
13888 29325 customsfxdata[j].param = temp_sample->param;
13889 29325 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13890 29325 i=j;
13891 29325 }
13892 115 }
13893
13894 extern char *guy_string[eMAXGUYS];
13895 extern const char *old_guy_string[OLDMAXGUYS];
13896
13897 115 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13898 {
13899 dword dummy;
13900 word guy_cversion;
13901 115 word guyversion=0;
13902
13903
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version >= 0x193)
13904 {
13905 //section version info
13906
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&guyversion,f,true))
13907 {
13908 return qe_invalid;
13909 }
13910
13911 111 FFCore.quest_format[vGuys] = guyversion;
13912
13913 //al_trace("Guys version %d\n", guyversion);
13914
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&guy_cversion,f,true))
13915 {
13916 return qe_invalid;
13917 }
13918 111 al_trace("Guy CVersion is: %d\n", guy_cversion);
13919 //section size
13920
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
13921 {
13922 return qe_invalid;
13923 }
13924 111 }
13925
13926
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(guyversion > 3)
13927 {
13928
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 106 times.
54378 for(int32_t i=0; i<MAXGUYS; i++)
13929 {
13930 char tempname[64];
13931
13932 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13933 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13934
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54272 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13935 {
13936 memset(tempname, 0, sizeof(char)*64);
13937 sprintf(tempname, "e%03d", i);
13938 strcpy(guy_string[i], tempname);
13939
13940 continue;
13941 }
13942
13943
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!pfread(tempname, 64, f, keepdata))
13944 {
13945 return qe_invalid;
13946 }
13947
13948 // Don't retain names of uneditable enemy entries!
13949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
54272 if(keepdata)
13950 {
13951 // for version upgrade to 2.5
13952
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54272 if(guyversion < 23 && i >= 177)
13953 {
13954 // some of the older builds have names such as 'zz123',
13955 // (this order gets messed up with some eXXX and some zzXXX)
13956 // so let's update to the newer naming convection. -Gleeok
13957 char tmpbuf[64];
13958 memset(tmpbuf, 0, sizeof(char)*64);
13959 sprintf(tmpbuf, "zz%03d", i);
13960
13961 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13962 {
13963 memset(tempname, 0, sizeof(char)*64);
13964 sprintf(tempname, "e%03d", i);
13965 }
13966 }
13967
13968
6/6
✓ Branch 0 taken 18762 times.
✓ Branch 1 taken 35510 times.
✓ Branch 2 taken 17808 times.
✓ Branch 3 taken 954 times.
✓ Branch 4 taken 14846 times.
✓ Branch 5 taken 2962 times.
54272 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13969 {
13970 51310 guy_string[i][0] = '\0';
13971 51310 strncat(guy_string[i], tempname, 64 - 1);
13972 51310 }
13973 else
13974 {
13975 2962 strcpy(guy_string[i],old_guy_string[i]);
13976 }
13977 54272 }
13978 54272 }
13979 106 }
13980 else
13981 {
13982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13983 {
13984
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13985 {
13986 4608 sprintf(guy_string[i],"zz%03d",i);
13987 4608 }
13988
13989
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13990 {
13991 1593 strcpy(guy_string[i],old_guy_string[i]);
13992 1593 }
13993 9 }
13994 }
13995
13996
13997 //finally... section data
13998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata)
13999 {
14000 115 init_guys(guyversion); //using default data for now...
14001
14002 // Goriya guy fix
14003
3/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
14004 {
14005
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14006 {
14007 5 guysbuf[gGORIYA].tile=130;
14008 5 guysbuf[gGORIYA].e_tile=130;
14009 5 }
14010 9 }
14011 115 }
14012
14013
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(Header->zelda_version < 0x193)
14014 {
14015
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
14016 {
14017 guysbuf[eDODONGO].cset=14;
14018 guysbuf[eDODONGO].bosspal=spDIG;
14019 }
14020 4 }
14021 // Not sure when this first changed, but it's necessary for 2.10, at least
14022 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
14023 //2.10 Fixes
14024
3/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
14025 {
14026 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
14027 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
14028 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
14029 9 guysbuf[eCENT1].misc3 = 1;
14030 9 guysbuf[eCENT2].misc3 = 1;
14031 9 }
14032
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
14033 {
14034 115 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
14035 115 }
14036
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(Header->zelda_version <= 0x210)
14037 {
14038 9 guysbuf[eGLEEOK1F].misc6 = 16;
14039 9 guysbuf[eGLEEOK2F].misc6 = 16;
14040 9 guysbuf[eGLEEOK3F].misc6 = 16;
14041 9 guysbuf[eGLEEOK4F].misc6 = 16;
14042
14043 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
14044 9 guysbuf[eBATROBE].misc4 = 1;
14045 //guysbuf[eSUMMONER].misc4 = 1;
14046 9 guysbuf[eWWIZ].misc4 = 1;
14047 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14048 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14049 9 }
14050
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(Header->zelda_version == 0x190)
14051 {
14052 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
14053 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
14054 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
14055 4 }
14056
14057 // The versions here may not be correct
14058 // zelda_version>=0x211 handled at guyversion<24
14059
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version <= 0x190)
14060 {
14061 4 guysbuf[eCENT1].misc3 = 0;
14062 4 guysbuf[eCENT2].misc3 = 0;
14063 4 guysbuf[eMOLDORM].misc2 = 0;
14064 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
14065 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
14066 4 }
14067
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 else if(Header->zelda_version <= 0x210)
14068 {
14069 5 guysbuf[eCENT1].misc3 = 1;
14070 5 guysbuf[eCENT2].misc3 = 1;
14071 5 guysbuf[eMOLDORM].misc2 = 0;
14072 5 }
14073
14074
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
14075 {
14076 9 guysbuf[eKEESE1].misc16 = 120;
14077 9 guysbuf[eKEESE2].misc16 = 120;
14078 9 guysbuf[eKEESE3].misc16 = 120;
14079 9 guysbuf[eKEESETRIB].misc16 = 120;
14080 9 guysbuf[eKEESE1].misc17 = 16;
14081 9 guysbuf[eKEESE2].misc17 = 16;
14082 9 guysbuf[eKEESE3].misc17 = 16;
14083 9 guysbuf[eKEESETRIB].misc17 = 16;
14084
14085 9 guysbuf[ePEAHAT].misc16 = 80;
14086 9 guysbuf[ePEAHAT].misc17 = 16;
14087
14088 9 guysbuf[eGHINI2].misc16 = 120;
14089 9 guysbuf[eGHINI2].misc17 = 10;
14090
14091 9 }
14092
14093
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 if(guyversion<=2)
14094 {
14095 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
14096 }
14097
14098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(guyversion > 3)
14099 {
14100 guydata tempguy;
14101
14102
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 106 times.
54378 for(int32_t i=0; i<MAXGUYS; i++)
14103 {
14104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54272 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
14105 {
14106 if(i >= OLDBETAMAXGUYS)
14107 {
14108 memset(&guysbuf[i], 0, sizeof(guydata));
14109 continue;
14110 }
14111 }
14112
14113 54272 memset(&tempguy, 0, sizeof(guydata));
14114
14115
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.flags),f,keepdata))
14116 {
14117 return qe_invalid;
14118 }
14119
14120
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.flags2),f,keepdata))
14121 {
14122 return qe_invalid;
14123 }
14124
14125
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion >= 36 ) //expanded tiles
14126 {
14127
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.tile),f,keepdata))
14128 {
14129 return qe_invalid;
14130 }
14131 15360 }
14132 else
14133 {
14134
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.tile),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138 }
14139
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.width),f,keepdata))
14140 {
14141 return qe_invalid;
14142 }
14143
14144
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.height),f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148
14149
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion >= 36 ) //expanded tiles
14150 {
14151
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
14152 {
14153 return qe_invalid;
14154 }
14155 15360 }
14156 else
14157 {
14158
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14159 {
14160 return qe_invalid;
14161 }
14162 }
14163
14164
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.s_width),f,keepdata))
14165 {
14166 return qe_invalid;
14167 }
14168
14169
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.s_height),f,keepdata))
14170 {
14171 return qe_invalid;
14172 }
14173
14174
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion >= 36 ) //expanded tiles
14175 {
14176
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14177 {
14178 return qe_invalid;
14179 }
14180 15360 }
14181 else
14182 {
14183
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14184 {
14185 return qe_invalid;
14186 }
14187 }
14188
14189
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.e_width),f,keepdata))
14190 {
14191 return qe_invalid;
14192 }
14193
14194
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.e_height),f,keepdata))
14195 {
14196 return qe_invalid;
14197 }
14198
14199
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.hp),f,keepdata))
14200 {
14201 return qe_invalid;
14202 }
14203
14204
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.family),f,keepdata))
14205 {
14206 return qe_invalid;
14207 }
14208
14209
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
54272 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14210 {
14211 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14212 {
14213 tempguy.s_tile=tempguy.e_tile+120;
14214 tempguy.s_width=tempguy.e_width;
14215 tempguy.s_height=tempguy.e_height;
14216 }
14217 else tempguy.s_tile=860;
14218 }
14219
14220
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.cset),f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.anim),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.frate),f,keepdata))
14236 {
14237 return qe_invalid;
14238 }
14239
14240
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14241 {
14242 return qe_invalid;
14243 }
14244
14245
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 13) // April 2009
14246 {
14247 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14248 {
14249 tempguy.frate *= 2;
14250 tempguy.e_frate *= 2;
14251 }
14252 }
14253
14254
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 14) // May 1 2009
14255 {
14256 if(tempguy.anim==a2FRMSLOW)
14257 {
14258 tempguy.anim=a2FRM;
14259 tempguy.frate *= 2;
14260 }
14261
14262 if(tempguy.e_anim==a2FRMSLOW)
14263 {
14264 tempguy.e_anim=a2FRM;
14265 tempguy.e_frate *= 2;
14266 }
14267
14268 if(tempguy.anim==aFLIPSLOW)
14269 {
14270 tempguy.anim=aFLIP;
14271 tempguy.frate *= 2;
14272 }
14273
14274 if(tempguy.e_anim==aFLIPSLOW)
14275 {
14276 tempguy.e_anim=aFLIP;
14277 tempguy.e_frate *= 2;
14278 }
14279
14280 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14281
14282 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14283
14284 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14285 {
14286 tempguy.anim=a4FRM4DIR;
14287 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14288 }
14289
14290 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14291 {
14292 tempguy.e_anim=a4FRM4DIR;
14293 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14294 }
14295 }
14296
14297
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.dp),f,keepdata))
14298 {
14299 return qe_invalid;
14300 }
14301
14302 //correction for guy fire
14303
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 6)
14304 {
14305 if(i == gFIRE)
14306 tempguy.dp = 2;
14307 }
14308
14309
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14310 {
14311 return qe_invalid;
14312 }
14313
14314
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14315 {
14316 return qe_invalid;
14317 }
14318
14319 //correction for bosses using triple, "rising" fireballs
14320
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 5)
14321 {
14322 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14323 i == eGOHMA3 || i == eGOHMA4)
14324 {
14325 if(tempguy.weapon == ewFireball)
14326 tempguy.weapon = ewFireball2;
14327 }
14328 }
14329
14330
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.rate),f,keepdata))
14331 {
14332 return qe_invalid;
14333 }
14334
14335
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14336 {
14337 return qe_invalid;
14338 }
14339
14340
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.step),f,keepdata))
14341 {
14342 return qe_invalid;
14343 }
14344
14345 // HIGHLY UNORTHODOX UPDATING THING, part 2
14346
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 52736 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
54272 if(fixpolsvoice && tempguy.family==eePOLSV)
14347 {
14348 tempguy.step /= 2;
14349 }
14350
14351
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.homing),f,keepdata))
14352 {
14353 return qe_invalid;
14354 }
14355
14356
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14357 {
14358 return qe_invalid;
14359 }
14360
14361
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14362 {
14363 return qe_invalid;
14364 }
14365
14366
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14367 {
14368
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14369 {
14370 return qe_invalid;
14371 }
14372
14373
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14374 {
14375 return qe_invalid;
14376 }
14377
14378
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14379 {
14380 return qe_invalid;
14381 }
14382
14383
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14384 {
14385 return qe_invalid;
14386 }
14387
14388
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14389 {
14390 return qe_invalid;
14391 }
14392
14393
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14394 {
14395 return qe_invalid;
14396 }
14397
14398
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14399 {
14400 return qe_invalid;
14401 }
14402
14403
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14404 {
14405 return qe_invalid;
14406 }
14407
14408
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14409 {
14410 return qe_invalid;
14411 }
14412
14413
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14414 {
14415 return qe_invalid;
14416 }
14417 54272 }
14418 else
14419 {
14420 int16_t tempMisc;
14421
14422 if(!p_igetw(&tempMisc,f,keepdata))
14423 {
14424 return qe_invalid;
14425 }
14426
14427 tempguy.misc1=tempMisc;
14428
14429 if(!p_igetw(&tempMisc,f,keepdata))
14430 {
14431 return qe_invalid;
14432 }
14433
14434 tempguy.misc2=tempMisc;
14435
14436 if(!p_igetw(&tempMisc,f,keepdata))
14437 {
14438 return qe_invalid;
14439 }
14440
14441 tempguy.misc3=tempMisc;
14442
14443 if(!p_igetw(&tempMisc,f,keepdata))
14444 {
14445 return qe_invalid;
14446 }
14447
14448 tempguy.misc4=tempMisc;
14449
14450 if(!p_igetw(&tempMisc,f,keepdata))
14451 {
14452 return qe_invalid;
14453 }
14454
14455 tempguy.misc5=tempMisc;
14456
14457 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14458 {
14459 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14460 tempguy.misc5 = 74;
14461 }
14462
14463 if(!p_igetw(&tempMisc,f,keepdata))
14464 {
14465 return qe_invalid;
14466 }
14467
14468 tempguy.misc6=tempMisc;
14469
14470 if(!p_igetw(&tempMisc,f,keepdata))
14471 {
14472 return qe_invalid;
14473 }
14474
14475 tempguy.misc7=tempMisc;
14476
14477 if(!p_igetw(&tempMisc,f,keepdata))
14478 {
14479 return qe_invalid;
14480 }
14481
14482 tempguy.misc8=tempMisc;
14483
14484 if(!p_igetw(&tempMisc,f,keepdata))
14485 {
14486 return qe_invalid;
14487 }
14488
14489 tempguy.misc9=tempMisc;
14490
14491 if(!p_igetw(&tempMisc,f,keepdata))
14492 {
14493 return qe_invalid;
14494 }
14495
14496 tempguy.misc10=tempMisc;
14497 }
14498
14499
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14500 {
14501 return qe_invalid;
14502 }
14503
14504
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14505 {
14506 return qe_invalid;
14507 }
14508
14509
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetw(&(tempguy.extend),f,keepdata))
14510 {
14511 return qe_invalid;
14512 }
14513
14514 //! Enemy Defences
14515
14516 //If a 2.50 quest, use only the 2.5 defences.
14517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
54272 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14518 {
14519
2/2
✓ Branch 0 taken 1031168 times.
✓ Branch 1 taken 54272 times.
1085440 for(int32_t j=0; j<edefLAST; j++)
14520 {
14521
1/2
✓ Branch 0 taken 1031168 times.
✗ Branch 1 not taken.
1031168 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14522 {
14523 return qe_invalid;
14524 }
14525 1031168 }
14526 //then copy the generic script defence to all the new script defences
14527
14528 54272 }
14529
14530
14531
14532
14533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
54272 if(guyversion >= 18)
14534 {
14535
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539
14540
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14541 {
14542 return qe_invalid;
14543 }
14544 54272 }
14545
14546
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion >= 22)
14547 {
14548
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14549 {
14550 return qe_invalid;
14551 }
14552
14553
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14554 {
14555 return qe_invalid;
14556 }
14557 54272 }
14558 else if(guyversion >= 19)
14559 {
14560 int16_t tempMisc;
14561
14562 if(!p_igetw(&tempMisc,f,keepdata))
14563 {
14564 return qe_invalid;
14565 }
14566
14567 tempguy.misc11=tempMisc;
14568
14569 if(!p_igetw(&tempMisc,f,keepdata))
14570 {
14571 return qe_invalid;
14572 }
14573
14574 tempguy.misc12=tempMisc;
14575 }
14576
14577 //If a 2.54 or later quest, use all of the defences.
14578
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion > 24) // Add new guyversion conditional statement
14579 {
14580
2/2
✓ Branch 0 taken 337920 times.
✓ Branch 1 taken 15360 times.
353280 for(int32_t j=edefLAST; j<edefLAST255; j++)
14581 {
14582
1/2
✓ Branch 0 taken 337920 times.
✗ Branch 1 not taken.
337920 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14583 {
14584 return qe_invalid;
14585 }
14586 337920 }
14587 15360 }
14588
14589
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14590 {
14591
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14592 {
14593 389120 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14594 389120 }
14595 38912 }
14596
14597 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14598
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion > 25)
14599 {
14600
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14601 {
14602 return qe_invalid;
14603 }
14604
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14605 {
14606 return qe_invalid;
14607 }
14608
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14609 {
14610 return qe_invalid;
14611 }
14612
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14613 {
14614 return qe_invalid;
14615 }
14616
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14617 {
14618 return qe_invalid;
14619 }
14620 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14621
14622 */
14623 15360 }
14624 //More Enemy Editor vars for 2.60
14625
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion > 26)
14626 {
14627
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14628 {
14629 return qe_invalid;
14630 }
14631
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14632 {
14633 return qe_invalid;
14634 }
14635
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14636 {
14637 return qe_invalid;
14638 }
14639
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14640 {
14641 return qe_invalid;
14642 }
14643
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14644 {
14645 return qe_invalid;
14646 }
14647 15360 }
14648
14649
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14650 {
14651 38912 tempguy.wpnsprite = 0;
14652 38912 }
14653
14654
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion > 27)
14655 {
14656
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14657 {
14658 return qe_invalid;
14659 }
14660 15360 }
14661
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14662 {
14663 38912 tempguy.SIZEflags = 0;
14664 38912 }
14665
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion > 28)
14666 {
14667
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14668 {
14669 return qe_invalid;
14670 }
14671
14672 15360 }
14673
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14674 {
14675 38912 tempguy.frozentile = 0;
14676 38912 tempguy.frozencset = 0;
14677 38912 tempguy.frozenclock = 0;
14678
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14679 38912 }
14680
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion >= 30)
14681 {
14682
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14683 {
14684 return qe_invalid;
14685 }
14686
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14687 {
14688 return qe_invalid;
14689 }
14690
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14691 {
14692 return qe_invalid;
14693 }
14694
2/2
✓ Branch 0 taken 153600 times.
✓ Branch 1 taken 15360 times.
168960 for ( int32_t q = 0; q < 10; q++ ) {
14695
1/2
✓ Branch 0 taken 153600 times.
✗ Branch 1 not taken.
153600 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14696 {
14697 return qe_invalid;
14698 }
14699 153600 }
14700
14701 15360 }
14702
14703
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion >= 34)
14704 {
14705
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14706 {
14707 return qe_invalid;
14708 }
14709
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14710 {
14711 return qe_invalid;
14712 }
14713
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14714 {
14715 return qe_invalid;
14716 }
14717
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14718 {
14719 return qe_invalid;
14720 }
14721
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14722 {
14723 return qe_invalid;
14724 }
14725
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14726 {
14727 return qe_invalid;
14728 }
14729
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14730 {
14731 return qe_invalid;
14732 }
14733
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14734 {
14735 return qe_invalid;
14736 }
14737
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14738 {
14739 return qe_invalid;
14740 }
14741
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14742 {
14743 return qe_invalid;
14744 }
14745
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14746 {
14747 return qe_invalid;
14748 }
14749
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14750 {
14751 return qe_invalid;
14752 }
14753
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14754 {
14755 return qe_invalid;
14756 }
14757
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14758 {
14759 return qe_invalid;
14760 }
14761
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14762 {
14763 return qe_invalid;
14764 }
14765
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14766 {
14767 return qe_invalid;
14768 }
14769
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14770 {
14771 return qe_invalid;
14772 }
14773
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14774 {
14775 return qe_invalid;
14776 }
14777
14778
2/2
✓ Branch 0 taken 491520 times.
✓ Branch 1 taken 15360 times.
506880 for ( int32_t q = 0; q < 32; q++ ) {
14779
1/2
✓ Branch 0 taken 491520 times.
✗ Branch 1 not taken.
491520 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14780 {
14781 return qe_invalid;
14782 }
14783 491520 }
14784
2/2
✓ Branch 0 taken 491520 times.
✓ Branch 1 taken 15360 times.
506880 for ( int32_t q = 0; q < 32; q++ ) {
14785
1/2
✓ Branch 0 taken 491520 times.
✗ Branch 1 not taken.
491520 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14786 {
14787 return qe_invalid;
14788 }
14789 491520 }
14790
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.script),f,keepdata))
14791 {
14792 return qe_invalid;
14793 }
14794 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14795
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14796 {
14797
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14798 {
14799 return qe_invalid;
14800 }
14801 122880 }
14802
2/2
✓ Branch 0 taken 30720 times.
✓ Branch 1 taken 15360 times.
46080 for ( int32_t q = 0; q < 2; q++ )
14803 {
14804
1/2
✓ Branch 0 taken 30720 times.
✗ Branch 1 not taken.
30720 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14805 {
14806 return qe_invalid;
14807 }
14808 30720 }
14809
14810 15360 }
14811
14812
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion >= 37)
14813 {
14814
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14815 {
14816 return qe_invalid;
14817 }
14818 15360 }
14819
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14820
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if(guyversion >= 38)
14821 {
14822
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14823 {
14824 return qe_invalid;
14825 }
14826
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14827 {
14828 return qe_invalid;
14829 }
14830
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14831 {
14832 return qe_invalid;
14833 }
14834
14835 15360 }
14836
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion < 38 )
14837 {
14838 38912 tempguy.misc13 = 0;
14839 38912 tempguy.misc14 = 0;
14840 38912 tempguy.misc15 = 0;
14841 38912 }
14842
14843
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if ( guyversion >= 39 )
14844 {
14845
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14846 {
14847
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
14848 {
14849
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14850 {
14851 return qe_invalid;
14852 }
14853 7987200 }
14854
2/2
✓ Branch 0 taken 7987200 times.
✓ Branch 1 taken 122880 times.
8110080 for ( int32_t w = 0; w < 65; w++ )
14855 {
14856
1/2
✓ Branch 0 taken 7987200 times.
✗ Branch 1 not taken.
7987200 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14857 {
14858 return qe_invalid;
14859 }
14860 7987200 }
14861 122880 }
14862
14863
14864 15360 }
14865
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion < 39 ) //apply old InitD strings to both
14866 {
14867
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ )
14868 {
14869 311296 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14870 311296 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14871 311296 }
14872 38912 }
14873
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if ( guyversion >= 40 )
14874 {
14875
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14876 {
14877 return qe_invalid;
14878 }
14879 15360 }
14880
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if ( guyversion < 40 )
14881 {
14882 38912 tempguy.weaponscript = 0;
14883 38912 }
14884 //eweapon script InitD
14885
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
54272 if ( guyversion >= 41 )
14886 {
14887
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 15360 times.
138240 for ( int32_t q = 0; q < 8; q++ )
14888 {
14889
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14890 {
14891 return qe_invalid;
14892 }
14893 122880 }
14894
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if ( guy_cversion < 4 )
14895 {
14896 if ( tempguy.family == eeKEESE )
14897 {
14898
14899 if ( !tempguy.misc1 )
14900 {
14901 tempguy.misc16 = 120;
14902 tempguy.misc17 = 16;
14903
14904 }
14905 }
14906 if ( tempguy.family == eePEAHAT )
14907 {
14908 tempguy.misc16 = 80;
14909 tempguy.misc17 = 16;
14910 }
14911
14912 if ( tempguy.family == eeGHINI )
14913 {
14914 tempguy.misc16 = 120;
14915 tempguy.misc17 = 10;
14916 }
14917
14918 }
14919 15360 }
14920
14921
14922
14923 //default weapon sprites (quest version < 2.54)
14924 //port over old defaults -Z
14925
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 32)
14926 {
14927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.wpnsprite <= 0 )
14928 {
14929
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14930 {
14931 case wNone:
14932 32390 tempguy.wpnsprite = 0; break;
14933
14934 case wSword:
14935 case wBeam:
14936 case wBrang:
14937 case wBomb:
14938 case wSBomb:
14939 case wLitBomb:
14940 case wLitSBomb:
14941 case wArrow:
14942 case wFire:
14943 case wWhistle:
14944 case wBait:
14945 case wWand:
14946 case wMagic:
14947 case wCatching:
14948 case wWind:
14949 case wRefMagic:
14950 case wRefFireball:
14951 case wRefRock:
14952 case wHammer:
14953 case wHookshot:
14954 case wHSHandle:
14955 case wHSChain:
14956 case wSSparkle:
14957 case wFSparkle:
14958 case wSmack:
14959 case wPhantom:
14960 case wCByrna:
14961 case wRefBeam:
14962 case wStomp:
14963 case lwMax:
14964 case wScript1:
14965 case wScript2:
14966 case wScript3:
14967 case wScript4:
14968 case wScript5:
14969 case wScript6:
14970 case wScript7:
14971 case wScript8:
14972 case wScript9:
14973 case wScript10:
14974 case wIce:
14975 //Cannot use any of these weapons yet.
14976 tempguy.wpnsprite = -1;
14977 break;
14978
14979 case wEnemyWeapons:
14980 1292 case ewFireball: tempguy.wpnsprite = 17; break;
14981
14982 299 case ewArrow: tempguy.wpnsprite = 19; break;
14983 311 case ewBrang: tempguy.wpnsprite = 4; break;
14984 924 case ewSword: tempguy.wpnsprite = 20; break;
14985 488 case ewRock: tempguy.wpnsprite = 18; break;
14986 904 case ewMagic: tempguy.wpnsprite = 21; break;
14987 79 case ewBomb: tempguy.wpnsprite = 78; break;
14988 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14989 135 case ewLitBomb: tempguy.wpnsprite = 76; break;
14990 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14991 359 case ewFireTrail: tempguy.wpnsprite = 80; break;
14992 751 case ewFlame: tempguy.wpnsprite = 35; break;
14993 105 case ewWind: tempguy.wpnsprite = 36; break;
14994 79 case ewFlame2: tempguy.wpnsprite = 81; break;
14995 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14996 case ewIce: tempguy.wpnsprite = 83; break;
14997 759 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14998
14999
15000 default: break; //No assign.
15001 }
15002 38912 }
15003 38912 }
15004
15005 //default weapon fire sound (quest version < 2.54)
15006 //port over old defaults and zero new data. -Z
15007
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 34)
15008 {
15009
2/2
✓ Branch 0 taken 1245184 times.
✓ Branch 1 taken 38912 times.
1284096 for ( int32_t q = 0; q < 32; q++ )
15010 {
15011 1245184 tempguy.movement[q] = 0;
15012 1245184 tempguy.new_weapon[q] = 0;
15013
15014 1245184 }
15015
15016 //NPC Script attributes.
15017 38912 tempguy.script = 0; //No scripted enemies existed. -Z
15018
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
15019
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 38912 times.
116736 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
15020
15021 38912 tempguy.misc16 = 0;
15022 38912 tempguy.misc17 = 0;
15023 38912 tempguy.misc18 = 0;
15024 38912 tempguy.misc19 = 0;
15025 38912 tempguy.misc20 = 0;
15026 38912 tempguy.misc21 = 0;
15027 38912 tempguy.misc22 = 0;
15028 38912 tempguy.misc23 = 0;
15029 38912 tempguy.misc24 = 0;
15030 38912 tempguy.misc25 = 0;
15031 38912 tempguy.misc26 = 0;
15032 38912 tempguy.misc27 = 0;
15033 38912 tempguy.misc28 = 0;
15034 38912 tempguy.misc29 = 0;
15035 38912 tempguy.misc30 = 0;
15036 38912 tempguy.misc31 = 0;
15037 38912 tempguy.misc32 = 0;
15038
15039 //old default sounds
15040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.firesfx <= 0 )
15041 {
15042
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
15043 {
15044 case wNone:
15045 32390 tempguy.firesfx = 0; break;
15046
15047 case wSword:
15048 case wBeam:
15049 case wBrang:
15050 case wBomb:
15051 case wSBomb:
15052 case wLitBomb:
15053 case wLitSBomb:
15054 case wArrow:
15055 case wFire:
15056 case wWhistle:
15057 case wBait:
15058 case wWand:
15059 case wMagic:
15060 case wCatching:
15061 case wWind:
15062 case wRefMagic:
15063 case wRefFireball:
15064 case wRefRock:
15065 case wHammer:
15066 case wHookshot:
15067 case wHSHandle:
15068 case wHSChain:
15069 case wSSparkle:
15070 case wFSparkle:
15071 case wSmack:
15072 case wPhantom:
15073 case wCByrna:
15074 case wRefBeam:
15075 case wStomp:
15076 case lwMax:
15077 case wScript1:
15078 case wScript2:
15079 case wScript3:
15080 case wScript4:
15081 case wScript5:
15082 case wScript6:
15083 case wScript7:
15084 case wScript8:
15085 case wScript9:
15086 case wScript10:
15087 case wIce:
15088 //Cannot use any of these weapons yet.
15089 tempguy.firesfx = -1;
15090 break;
15091
15092 case wEnemyWeapons:
15093 1292 case ewFireball: tempguy.firesfx = 40; break;
15094
15095 299 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
15096 311 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
15097 924 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
15098 488 case ewRock: tempguy.firesfx = 51; break;
15099 904 case ewMagic: tempguy.firesfx = 32; break;
15100 79 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
15101 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
15102 135 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
15103 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
15104 359 case ewFireTrail: tempguy.firesfx = 13; break;
15105 751 case ewFlame: tempguy.firesfx = 13; break;
15106 105 case ewWind: tempguy.firesfx = 32; break;
15107 79 case ewFlame2: tempguy.firesfx = 13; break;
15108 case ewFlame2Trail: tempguy.firesfx = 13; break;
15109 case ewIce: tempguy.firesfx = 44; break;
15110 759 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
15111
15112 //what about special attacks (e.g. summoning == 56)
15113 default: break; //No assign.
15114 }
15115 38912 }
15116 38912 }
15117
15118 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
15119
4/6
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 15360 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15360 times.
54272 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
15120 {
15121
2/2
✓ Branch 0 taken 3527 times.
✓ Branch 1 taken 35385 times.
38912 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
15122 38912 }
15123 //Keese and bat halt rates.
15124
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 15360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
54272 if ( guyversion < 42 && guy_cversion < 4 )
15125 {
15126
15127
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 524 times.
38912 if ( tempguy.family == eeKEESE )
15128 {
15129
15130
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 322 times.
524 if ( !tempguy.misc1 )
15131 {
15132 322 tempguy.misc16 = 120;
15133 322 tempguy.misc17 = 16;
15134
15135 322 }
15136 524 }
15137
2/2
✓ Branch 0 taken 38747 times.
✓ Branch 1 taken 165 times.
38912 if ( tempguy.family == eePEAHAT )
15138 {
15139 165 tempguy.misc16 = 80;
15140 165 tempguy.misc17 = 16;
15141 165 }
15142
2/2
✓ Branch 0 taken 38836 times.
✓ Branch 1 taken 76 times.
38912 if ( tempguy.family == eeGHINI )
15143 {
15144 76 tempguy.misc16 = 120;
15145 76 tempguy.misc17 = 10;
15146 76 }
15147
15148
15149 38912 }
15150
15151
15152 //miscellaneous other corrections
15153 //fix the mirror wizzrobe -DD
15154
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 7)
15155 {
15156 if(i == eMWIZ)
15157 {
15158 tempguy.misc2 = 0;
15159 tempguy.misc4 = 1;
15160 }
15161 }
15162
15163
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 8)
15164 {
15165 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15166 {
15167 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15168 tempguy.misc5 = 4; //neck length in segments
15169 tempguy.misc6 = 8; //neck offset from first body tile
15170 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15171 tempguy.misc8 = 168; //head offset from first body tile
15172 tempguy.misc9 = 228; //flying head offset from first body tile
15173
15174 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15175 {
15176 tempguy.misc6 += 10; //neck offset from first body tile
15177 tempguy.misc8 -= 12; //head offset from first body tile
15178 }
15179 }
15180 }
15181
15182
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15183 {
15184 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15185 tempguy.bosspal = spDIG;
15186 }
15187
15188
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 11) // December 2007 - Spinning Tile fix
15189 {
15190 if(tempguy.family==eeSPINTILE)
15191 {
15192 tempguy.flags |= guy_superman;
15193 tempguy.item_set = 0; // Don't drop items
15194 tempguy.step = 300;
15195 }
15196 }
15197
15198
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15199 {
15200 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15201 {
15202 if(tempguy.family==eeROPE)
15203 {
15204 tempguy.flags2 &= ~guy_flashing;
15205 }
15206 }
15207
15208 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15209 {
15210 if(tempguy.family==eeBUBBLE)
15211 {
15212 tempguy.flags2 &= ~guy_flashing;
15213 }
15214 }
15215
15216 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15217 {
15218 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15219 {
15220 tempguy.flags2 |= guy_blinking;
15221 }
15222
15223 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15224 {
15225 tempguy.flags2 |= guy_transparent;
15226 }
15227 }
15228 }
15229
15230
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15231 {
15232 if(i==gFIRE)
15233 {
15234 tempguy.e_anim = aFLIP;
15235 tempguy.e_frate = 24;
15236 }
15237
15238 if(i==gFAIRY)
15239 {
15240 tempguy.e_anim = a2FRM;
15241 tempguy.e_frate = 16;
15242 }
15243 }
15244
15245
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15246 {
15247 if(i==0) Z_message("Updating guys to version 16...\n");
15248
15249 update_guy_1(&tempguy);
15250
15251 if(i==eMPOLSV)
15252 {
15253 tempguy.defense[edefARROW] = edCHINK;
15254 tempguy.defense[edefMAGIC] = ed1HKO;
15255 tempguy.defense[edefREFMAGIC] = ed1HKO;
15256 }
15257 }
15258
15259
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 17) // December 2009
15260 {
15261 if(tempguy.family==eePROJECTILE)
15262 {
15263 tempguy.misc1 = 0;
15264 }
15265 }
15266
15267
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 18) // January 2010
15268 {
15269 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15270 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15271
15272 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15273 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15274
15275 if(tempguy.family == eeAQUA)
15276 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15277 else if(tempguy.family == eeMANHAN)
15278 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15279 else if(tempguy.family==eePATRA)
15280 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15281 else if(tempguy.family==eeGHOMA)
15282 {
15283 for(int32_t j=0; j<edefLAST; j++)
15284 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15285
15286 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15287
15288 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15289
15290 tempguy.misc1--;
15291 }
15292 else if(tempguy.family == eeGLEEOK)
15293 {
15294 for(int32_t j=0; j<edefLAST; j++)
15295 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15296
15297 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15298 }
15299 else if(tempguy.family == eeARMOS)
15300 {
15301 tempguy.family=eeWALK;
15302 tempguy.hrate = 0;
15303 tempguy.misc10 = tempguy.misc1;
15304 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15305 tempguy.misc9 = e9tARMOS;
15306 }
15307 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15308 {
15309 tempguy.family=eeWALK;
15310 tempguy.hrate = 0;
15311 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15312 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15313 }
15314
15315 // Spawn animation flags
15316 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15317 tempguy.flags |= guy_fadeflicker;
15318 else
15319 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15320 }
15321
15322
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 20) // April 2010
15323 {
15324 if(tempguy.family == eeTRAP)
15325 {
15326 tempguy.misc2 = tempguy.misc10;
15327
15328 if(tempguy.misc10>=1)
15329 {
15330 tempguy.misc1++;
15331 }
15332
15333 tempguy.misc10 = 0;
15334 }
15335
15336 // Bomb Blast fix
15337 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15338 tempguy.weapon = ewLitBomb;
15339 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15340 tempguy.weapon = ewLitSBomb;
15341 }
15342
15343
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 21) // September 2011
15344 {
15345 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15346 {
15347 if(tempguy.family == eeKEESETRIB)
15348 {
15349 tempguy.family = eeKEESE;
15350 tempguy.misc2 = e2tKEESETRIB;
15351 tempguy.misc1 = 0;
15352 }
15353
15354 tempguy.rate = 2;
15355 tempguy.hrate = 8;
15356 tempguy.homing = 0;
15357 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15358 }
15359 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15360 {
15361 if(tempguy.family == eePEAHAT)
15362 {
15363 tempguy.rate = 4;
15364 tempguy.step = 62;
15365 }
15366 else
15367 tempguy.step = 25;
15368
15369 tempguy.hrate = 8;
15370 tempguy.homing = 0;
15371 }
15372 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15373 {
15374 if(tempguy.family == eeMANHAN)
15375 tempguy.step=50;
15376
15377 tempguy.hrate = 16;
15378 tempguy.homing = 0;
15379 }
15380 else if(tempguy.family == eeGLEEOK)
15381 {
15382 tempguy.rate = 2;
15383 tempguy.homing = 0;
15384 tempguy.hrate = 9;
15385 tempguy.step=89;
15386 }
15387 else if(tempguy.family == eeGHINI)
15388 {
15389 tempguy.rate = 4;
15390 tempguy.hrate = 12;
15391 tempguy.step=62;
15392 tempguy.homing = 0;
15393 }
15394
15395 // Bigdig random rate fix
15396 if(tempguy.family==eeDIG && tempguy.misc10==1)
15397 {
15398 tempguy.rate = 2;
15399 }
15400 }
15401
15402
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if(guyversion < 24) // November 2012
15403 {
15404 if(tempguy.family==eeLANM)
15405 tempguy.misc3 = 1;
15406 else if(tempguy.family==eeMOLD)
15407 tempguy.misc2 = 0;
15408 }
15409
15410
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15411 {
15412
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 38258 times.
38912 if(tempguy.family!=eeDIG)
15413 {
15414 38258 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15415 38258 }
15416
15417 38912 }
15418 // does not seem to solve the issue!
15419
1/2
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
54272 if ( Header->zelda_version <= 0x210 )
15420 {
15421 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15422 if ( tempguy.family == eeDONGO )
15423 {
15424 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15425 }
15426 }
15427
15428
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion >= 42)
15429 {
15430
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 1024 times.
15360 if(guyversion >= 47)
15431 {
15432
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15433 {
15434 return qe_invalid;
15435 }
15436 14336 }
15437 else
15438 {
15439 byte fl;
15440
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15441 {
15442 return qe_invalid;
15443 }
15444 1024 tempguy.moveflags = fl;
15445 }
15446 15360 }
15447 else
15448 {
15449
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30458 times.
✓ Branch 2 taken 1192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 275 times.
✓ Branch 6 taken 239 times.
✓ Branch 7 taken 5787 times.
38912 switch(tempguy.family)
15450 {
15451 //No gravity; floats over pits
15452 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15453 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15454 //Special (bosses, etc)
15455 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15456 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15457 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15458 30458 tempguy.moveflags = FLAG_CAN_PITWALK;
15459 30458 break;
15460 //No gravity, but falls in pits
15461 case eeLEV:
15462 515 tempguy.moveflags = FLAG_CAN_PITFALL;
15463 515 break;
15464 //Bosses that respect pits
15465 case eeDONGO:
15466 275 tempguy.moveflags = FLAG_OBEYS_GRAV;
15467 275 break;
15468 case eeLANM:
15469 239 tempguy.moveflags = 0;
15470 239 break;
15471 //Gravity, floats over pits
15472 case eeWIZZ: case eeWALLM: case eeGHINI:
15473 1192 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15474 1192 break;
15475 //Gravity and falls in pits
15476 case eeWALK:
15477
4/4
✓ Branch 0 taken 5469 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 5191 times.
5787 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15478 596 break;
15479 [[fallthrough]];
15480 case eeOTHER:
15481 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15482 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15483 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15484 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15485 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15486 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15487 5637 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15488 5637 }
15489 }
15490
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 43)
15491 {
15492
2/2
✓ Branch 0 taken 31650 times.
✓ Branch 1 taken 7262 times.
38912 switch(tempguy.family)
15493 {
15494 //No gravity; floats over pits
15495 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15496 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15497 //Special (bosses, etc)
15498 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15499 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15500 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15501 case eeWIZZ: case eeWALLM: case eeGHINI:
15502 //Gravity, floats over pits
15503 31650 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15504 31650 break;
15505 }
15506 38912 }
15507
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if (guyversion < 44)
15508 {
15509
2/2
✓ Branch 0 taken 38546 times.
✓ Branch 1 taken 366 times.
38912 if ( tempguy.family == eeGHOMA )
15510 {
15511 366 tempguy.flags |= guy_fadeinstant;
15512 366 }
15513 38912 }
15514
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if (guyversion > 44)
15515 {
15516
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15517 {
15518 return qe_invalid;
15519 }
15520
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15521 {
15522 return qe_invalid;
15523 }
15524
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15525 {
15526 return qe_invalid;
15527 }
15528 15360 }
15529 else
15530 {
15531
2/2
✓ Branch 0 taken 38761 times.
✓ Branch 1 taken 151 times.
38912 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15532 38912 tempguy.spr_death = iwDeath;
15533 38912 tempguy.spr_spawn = iwSpawn;
15534 }
15535
15536
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 38912 times.
54272 if(guyversion < 46)
15537 {
15538
4/4
✓ Branch 0 taken 5787 times.
✓ Branch 1 taken 33125 times.
✓ Branch 2 taken 5469 times.
✓ Branch 3 taken 318 times.
38912 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15539 {
15540 318 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15541 318 }
15542 38912 }
15543
15544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54272 times.
54272 if(keepdata)
15545 {
15546 54272 guysbuf[i] = tempguy;
15547 54272 }
15548 54272 }
15549 106 }
15550
15551 106 return 0;
15552 115 }
15553
15554 void update_guy_1(guydata *tempguy) // November 2009
15555 {
15556 bool doesntcount = false;
15557 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15558
15559 switch(tempguy->family)
15560 {
15561 case 1: //eeWALK
15562 switch(tempguy->misc10)
15563 {
15564 case 0: //Stalfos
15565 if(tempguy->misc1==1) // Fires four projectiles at once
15566 tempguy->misc1=4;
15567
15568 break;
15569
15570 case 1: //Darknut
15571 goto darknuts;
15572 break;
15573 }
15574
15575 tempguy->misc10 = 0;
15576 break;
15577
15578 case 2: //eeSHOOT
15579 tempguy->family = eeWALK;
15580
15581 switch(tempguy->misc10)
15582 {
15583 case 0: //Octorok
15584 if(tempguy->misc1==1||tempguy->misc1==2)
15585 {
15586 tempguy->misc1=e1tFIREOCTO;
15587 tempguy->misc2=e2tFIREOCTO;
15588 }
15589 else tempguy->misc1 = 0;
15590
15591 tempguy->misc6=tempguy->misc4;
15592 tempguy->misc4=tempguy->misc3;
15593 tempguy->misc3=0;
15594 break;
15595
15596 case 1: // Moblin
15597 tempguy->misc1 = 0;
15598 break;
15599
15600 case 2: //Lynel
15601 tempguy->misc6=tempguy->misc1+1;
15602 tempguy->misc1=0;
15603 break;
15604
15605 case 3: //Stalfos 2
15606 if(tempguy->misc1==1) // Fires four projectiles at once
15607 tempguy->misc1=e1t4SHOTS;
15608 else tempguy->misc1 = 0;
15609
15610 break;
15611
15612 case 4: //Darknut 5
15613 darknuts:
15614 tempguy->defense[edefFIRE] = edIGNORE;
15615 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15616 tempguy->defense[edefHOOKSHOT] = 0;
15617 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15618 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15619
15620 if(tempguy->misc1==1)
15621 tempguy->misc1=2;
15622 else if(tempguy->misc1==2)
15623 {
15624 tempguy->misc4=tempguy->misc3;
15625 tempguy->misc3=tempguy->misc2;
15626 tempguy->misc2=e2tSPLIT;
15627 tempguy->misc1 = 0;
15628 }
15629 else tempguy->misc1 = 0;
15630
15631 tempguy->flags |= inv_front;
15632
15633 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15634 tempguy->flags |= guy_bkshield;
15635
15636 break;
15637 }
15638
15639 tempguy->misc10 = 0;
15640 break;
15641
15642 /*
15643 case 9: //eeARMOS
15644 tempguy->family = eeWALK;
15645 break;
15646 */
15647 case 11: //eeGEL
15648 case 33: //eeGELTRIB
15649 if(tempguy->family==33)
15650 {
15651 tempguy->misc4 = 1;
15652
15653 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15654 tempguy->misc3 = tempguy->misc2;
15655
15656 tempguy->misc2 = e2tTRIBBLE;
15657 }
15658 else
15659 {
15660 tempguy->misc4 = 0;
15661 tempguy->misc3 = 0;
15662 tempguy->misc2 = 0;
15663 }
15664
15665 tempguy->family = eeWALK;
15666
15667 if(tempguy->misc1)
15668 {
15669 tempguy->misc1=1;
15670 tempguy->weapon = ewFireTrail;
15671 }
15672
15673 break;
15674
15675 case 34: //eeZOLTRIB
15676 case 12: //eeZOL
15677 tempguy->misc4=tempguy->misc3;
15678 tempguy->misc3=tempguy->misc2;
15679 tempguy->family = eeWALK;
15680 tempguy->misc2=e2tSPLITHIT;
15681
15682 if(tempguy->misc1)
15683 {
15684 tempguy->misc1=1;
15685 tempguy->weapon = ewFireTrail;
15686 }
15687
15688 break;
15689
15690 case 13: //eeROPE
15691 tempguy->family = eeWALK;
15692 tempguy->misc9 = e9tROPE;
15693
15694 if(tempguy->misc1)
15695 {
15696 tempguy->misc4 = tempguy->misc3;
15697 tempguy->misc3 = tempguy->misc2;
15698 tempguy->misc2 = e2tBOMBCHU;
15699 }
15700
15701 tempguy->misc1 = 0;
15702 break;
15703
15704 case 14: //eeGORIYA
15705 tempguy->family = eeWALK;
15706
15707 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15708
15709 break;
15710
15711 case 17: //eeBUBBLE
15712 tempguy->family = eeWALK;
15713 tempguy->misc8 = tempguy->misc2;
15714 tempguy->misc7 = tempguy->misc1 + 1;
15715 tempguy->misc1 = tempguy->misc2 = 0;
15716
15717 //fallthrogh
15718 case eeTRAP:
15719 case eeROCK:
15720 doesntcount = true;
15721 break;
15722
15723 case 35: //eeVIRETRIB
15724 case 18: //eeVIRE
15725 tempguy->family = eeWALK;
15726 tempguy->misc4=tempguy->misc3;
15727 tempguy->misc3=tempguy->misc2;
15728 tempguy->misc2=e2tSPLITHIT;
15729 tempguy->misc9=e9tVIRE;
15730 break;
15731
15732 case 19: //eeLIKE
15733 tempguy->family = eeWALK;
15734 tempguy->misc7 = e7tEATITEMS;
15735 tempguy->misc8=95;
15736 break;
15737
15738 case 20: //eePOLSV
15739 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15740 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15741 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15742 tempguy->defense[edefARROW] = ed1HKO;
15743 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15744 tempguy->family = eeWALK;
15745 tempguy->misc9 = e9tPOLSVOICE;
15746 tempguy->rate = 4;
15747 tempguy->homing = 32;
15748 tempguy->hrate = 10;
15749 tempguy->grumble = 0;
15750 break;
15751
15752 case eeWIZZ:
15753 if(tempguy->misc4)
15754 {
15755 for(int32_t i=0; i < edefLAST; i++)
15756 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15757 }
15758 else
15759 {
15760 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15761 tempguy->defense[edefMAGIC] = edCHINK;
15762 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15763 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15764 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15765 }
15766
15767 break;
15768
15769 case eePEAHAT:
15770 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15771
15772 if(!(tempguy->flags & guy_bhit))
15773 tempguy->defense[edefBRANG] = edSTUNONLY;
15774
15775 break;
15776
15777 case eeLEV:
15778 tempguy->defense[edefSTOMP] = edCHINK;
15779 break;
15780 }
15781
15782 // Old flags
15783 if(tempguy->flags & guy_superman)
15784 {
15785 for(int32_t i = 0; i < edefLAST; i++)
15786 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15787 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15788 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15789 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15790 }
15791
15792 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15793
15794 if(doesntcount)
15795 tempguy->flags |= (guy_doesntcount);
15796 }
15797
15798
15799 187744 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15800 {
15801 byte tempbyte, padding;
15802 int32_t extras, secretcombos;
15803 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->valid),f,true))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
15810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->guy),f,true))
15811 {
15812 return qe_invalid;
15813 }
15814
15815
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15816 {
15817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15818 {
15819 return qe_invalid;
15820 }
15821
15822 6864 temp_mapscr->str=tempbyte;
15823 6864 }
15824 else
15825 {
15826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->str),f,true))
15827 {
15828 return qe_invalid;
15829 }
15830 }
15831
15832
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->room),f,true))
15833 {
15834 return qe_invalid;
15835 }
15836
15837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->item),f,true))
15838 {
15839 return qe_invalid;
15840 }
15841
15842
3/6
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153000 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15843 {
15844 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15845 34744 }
15846 else
15847 {
15848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15849 return qe_invalid;
15850 }
15851
15852
2/4
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version < 0x192)||
15853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15854 {
15855
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15856 {
15857 return qe_invalid;
15858 }
15859 6864 }
15860
15861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15862 {
15863 return qe_invalid;
15864 }
15865
15866
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15867 {
15868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15869 {
15870 return qe_invalid;
15871 }
15872 6864 }
15873
15874
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15875 {
15876
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15877 {
15878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15879 {
15880 return qe_invalid;
15881 }
15882 459000 }
15883 153000 }
15884 else
15885 {
15886 34744 temp_mapscr->tilewarptype[1]=0;
15887 34744 temp_mapscr->tilewarptype[2]=0;
15888 34744 temp_mapscr->tilewarptype[3]=0;
15889 }
15890
15891
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15892 {
15893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15894 {
15895 return qe_invalid;
15896 }
15897 180880 }
15898
15899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15900 {
15901 return qe_invalid;
15902 }
15903
15904 187744 temp_mapscr->warpreturnx[1]=0;
15905 187744 temp_mapscr->warpreturnx[2]=0;
15906 187744 temp_mapscr->warpreturnx[3]=0;
15907
15908
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15909 {
15910
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15911 {
15912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15913 {
15914 return qe_invalid;
15915 }
15916 459000 }
15917 153000 }
15918
15919
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15920 {
15921 return qe_invalid;
15922 }
15923
15924 187744 temp_mapscr->warpreturny[1]=0;
15925 187744 temp_mapscr->warpreturny[2]=0;
15926 187744 temp_mapscr->warpreturny[3]=0;
15927
15928
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15929 {
15930
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15931 {
15932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15933 {
15934 return qe_invalid;
15935 }
15936 459000 }
15937
15938
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(version>=18)
15939 {
15940
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15941 {
15942 return qe_invalid;
15943 }
15944 153000 }
15945 else
15946 {
15947 byte temp;
15948
15949 if(!p_getc(&temp,f,true))
15950 {
15951 return qe_invalid;
15952 }
15953
15954 temp_mapscr->warpreturnc=temp<<8|temp;
15955 }
15956 153000 }
15957
15958
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->stairx),f,true))
15959
15960 {
15961 return qe_invalid;
15962 }
15963
15964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->stairy),f,true))
15965 {
15966 return qe_invalid;
15967 }
15968
15969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemx),f,true))
15970 {
15971 return qe_invalid;
15972 }
15973
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemy),f,true))
15975 {
15976 return qe_invalid;
15977 }
15978
15979
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version > 15) // February 2009
15980 {
15981
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->color),f,true))
15982 {
15983 return qe_invalid;
15984 }
15985 153000 }
15986 else
15987 {
15988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15989 {
15990 return qe_invalid;
15991 }
15992
15993 34744 temp_mapscr->color = (word) tempbyte;
15994 }
15995
15996
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15997 {
15998 return qe_invalid;
15999 }
16000
16001
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
16002 {
16003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->door[k]),f,true))
16004 {
16005 return qe_invalid;
16006
16007 }
16008 750976 }
16009
16010
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
16011 {
16012
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16013 {
16014 return qe_invalid;
16015 }
16016
16017 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
16018
16019
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16020 {
16021 for(int32_t i=1; i<4; i++)
16022 {
16023 if(!p_getc(&(tempbyte),f,true))
16024 {
16025 return qe_invalid;
16026 }
16027
16028 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
16029 }
16030 }
16031 else
16032 {
16033 34744 temp_mapscr->tilewarpdmap[1]=0;
16034 34744 temp_mapscr->tilewarpdmap[2]=0;
16035 34744 temp_mapscr->tilewarpdmap[3]=0;
16036 }
16037 34744 }
16038 else
16039 {
16040
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
16041 {
16042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
16043 {
16044 return qe_invalid;
16045 }
16046 612000 }
16047 }
16048
16049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
16050 {
16051 return qe_invalid;
16052 }
16053
16054
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16055 {
16056
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
16057 {
16058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
16059 {
16060 return qe_invalid;
16061 }
16062 459000 }
16063 153000 }
16064 else
16065 {
16066 34744 temp_mapscr->tilewarpscr[1]=0;
16067 34744 temp_mapscr->tilewarpscr[2]=0;
16068 34744 temp_mapscr->tilewarpscr[3]=0;
16069 }
16070
16071
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
16072 {
16073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
16074 {
16075 return qe_invalid;
16076 }
16077 153000 }
16078 else
16079 {
16080 34744 temp_mapscr->tilewarpoverlayflags=0;
16081 }
16082
16083
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->exitdir),f,true))
16084 {
16085 return qe_invalid;
16086 }
16087
16088
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
16089 {
16090
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
16091 {
16092 return qe_invalid;
16093 }
16094
16095 6864 }
16096
16097
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
16098 {
16099 if(!p_getc(&padding,f,true))
16100 {
16101 return qe_invalid;
16102 }
16103 }
16104
16105
2/2
✓ Branch 0 taken 1877440 times.
✓ Branch 1 taken 187744 times.
2065184 for(int32_t k=0; k<10; k++)
16106 {
16107 /*
16108 if (!temp_mapscr->enemy[k])
16109 {
16110 continue;
16111 }
16112 */
16113
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
16114 {
16115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16116 {
16117 return qe_invalid;
16118 }
16119
16120 68640 temp_mapscr->enemy[k]=tempbyte;
16121 68640 }
16122 else
16123 {
16124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1808800 times.
1808800 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
16125 {
16126 return qe_invalid;
16127 }
16128 }
16129
16130
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16131 {
16132 //using enumerations here is dangerous
16133 //very easy to break old quests -DD
16134
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16135 {
16136 788 temp_mapscr->enemy[k]+=5;
16137 788 }
16138
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16139 {
16140 40 temp_mapscr->enemy[k]+=1;
16141 40 }
16142 68640 }
16143
16144
2/2
✓ Branch 0 taken 1530000 times.
✓ Branch 1 taken 347440 times.
1877440 if(version < 9)
16145 {
16146
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
16147 {
16148 29025 temp_mapscr->enemy[k]+=10;
16149 29025 }
16150 347440 }
16151 //don't read in any invalid data
16152
2/2
✓ Branch 0 taken 1877420 times.
✓ Branch 1 taken 20 times.
1877440 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16153 {
16154 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16155 20 temp_mapscr->enemy[k] = 0;
16156 20 }
16157 1877440 }
16158
16159
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->pattern),f,true))
16160 {
16161 return qe_invalid;
16162 }
16163
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16165 {
16166 return qe_invalid;
16167 }
16168
16169
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16170 {
16171
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
16172 {
16173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16174 {
16175 return qe_invalid;
16176 }
16177 459000 }
16178 153000 }
16179 else
16180 {
16181 34744 temp_mapscr->sidewarptype[1]=0;
16182 34744 temp_mapscr->sidewarptype[2]=0;
16183 34744 temp_mapscr->sidewarptype[3]=0;
16184 }
16185
16186
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
16187 {
16188
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16189 {
16190 return qe_invalid;
16191 }
16192 153000 }
16193 else
16194 {
16195 34744 temp_mapscr->sidewarpoverlayflags=0;
16196 }
16197
16198
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16199 {
16200 return qe_invalid;
16201 }
16202
16203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16204 {
16205 return qe_invalid;
16206 }
16207
16208
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
16209 {
16210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16211 {
16212 return qe_invalid;
16213 }
16214 750976 }
16215
16216
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16217 {
16218 return qe_invalid;
16219 }
16220
16221
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16222 {
16223
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 459000 times.
612000 for(int32_t i=1; i<4; i++)
16224 {
16225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16226 {
16227 return qe_invalid;
16228 }
16229 459000 }
16230 153000 }
16231 else
16232 {
16233 34744 temp_mapscr->sidewarpscr[1]=0;
16234 34744 temp_mapscr->sidewarpscr[2]=0;
16235 34744 temp_mapscr->sidewarpscr[3]=0;
16236 }
16237
16238
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
16239 {
16240
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16241 {
16242 return qe_invalid;
16243 }
16244
16245 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16246
16247
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16248 {
16249 for(int32_t i=1; i<4; i++)
16250 {
16251 if(!p_getc(&(tempbyte),f,true))
16252 {
16253 return qe_invalid;
16254 }
16255
16256 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16257 }
16258 }
16259 else
16260 {
16261 34744 temp_mapscr->sidewarpdmap[1]=0;
16262 34744 temp_mapscr->sidewarpdmap[2]=0;
16263 34744 temp_mapscr->sidewarpdmap[3]=0;
16264 }
16265 34744 }
16266 else
16267 {
16268
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
16269 {
16270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16271 {
16272 return qe_invalid;
16273 }
16274 612000 }
16275 }
16276
16277
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16278 {
16279
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16280 {
16281 return qe_invalid;
16282 }
16283 153000 }
16284 34744 else temp_mapscr->sidewarpindex = 0;
16285
16286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16287 {
16288 return qe_invalid;
16289 }
16290
16291
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
16292 {
16293
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16294 {
16295 return qe_invalid;
16296 }
16297 6864 }
16298
16299
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16300 {
16301 return qe_invalid;
16302 }
16303
16304
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16305 {
16306 return qe_invalid;
16307 }
16308
16309
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->flags),f,true))
16310 {
16311 return qe_invalid;
16312 }
16313
16314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags2),f,true))
16315 {
16316 return qe_invalid;
16317 }
16318
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags3),f,true))
16320 {
16321 return qe_invalid;
16322 }
16323
16324
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16325 //if (version>2)
16326 {
16327
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags4),f,true))
16328 {
16329 return qe_invalid;
16330 }
16331 153000 }
16332
16333
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16334 {
16335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags5),f,true))
16336 {
16337 return qe_invalid;
16338 }
16339
16340
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16341 {
16342 return qe_invalid;
16343 }
16344
16345
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16346 {
16347 return qe_invalid;
16348 }
16349
16350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(temp_mapscr->flags5&32)
16351 {
16352 temp_mapscr->flags5 &= ~32;
16353 temp_mapscr->noreset |= 48;
16354 }
16355
16356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(version<8)
16357 {
16358 if(temp_mapscr->noreset&1)
16359 {
16360 temp_mapscr->noreset|=8192;
16361 }
16362
16363 if(temp_mapscr->nocarry&1)
16364 {
16365 temp_mapscr->nocarry|=8192;
16366 temp_mapscr->nocarry&=~1;
16367 }
16368 }
16369 153000 }
16370 else
16371 {
16372 34744 temp_mapscr->flags5 = 0;
16373 34744 temp_mapscr->noreset = 0;
16374 34744 temp_mapscr->nocarry = 0;
16375 }
16376
16377
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16378 {
16379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags6),f,true))
16380 {
16381 return qe_invalid;
16382 }
16383 153000 }
16384
16385
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>5)
16386 {
16387
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags7),f,true))
16388 {
16389 return qe_invalid;
16390 }
16391
16392
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags8),f,true))
16393 {
16394 return qe_invalid;
16395 }
16396
16397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags9),f,true))
16398 {
16399 return qe_invalid;
16400 }
16401
16402
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags10),f,true))
16403 {
16404 return qe_invalid;
16405 }
16406
16407
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16408 {
16409 return qe_invalid;
16410 }
16411 153000 }
16412 else
16413 {
16414 34744 temp_mapscr->csensitive=1;
16415 }
16416
16417
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<14) // August 2007: screen SFX added
16418 {
16419
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16420 {
16421 100 temp_mapscr->bosssfx=
16422
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16423 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16424 WAV_ROAR;
16425 100 }
16426
16427
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16428 {
16429 91 temp_mapscr->oceansfx=WAV_SEA;
16430 91 }
16431
16432 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16433 ? 0 : WAV_SECRET;
16434
16435 34744 temp_mapscr->flags3 &= ~66; //64|2
16436 34744 temp_mapscr->flags2 &= ~32;
16437 34744 temp_mapscr->flags &= ~136; // 128|8
16438 34744 }
16439 else
16440 {
16441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16442 {
16443 return qe_invalid;
16444 }
16445
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16447 {
16448 return qe_invalid;
16449 }
16450
16451
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16452 {
16453 return qe_invalid;
16454 }
16455 }
16456
16457
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<15) // October 2007: another SFX
16458 {
16459 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16460 34744 }
16461 else
16462 {
16463
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16464 {
16465 return qe_invalid;
16466 }
16467 }
16468
16469
16470
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16471 {
16472
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16473 {
16474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16475 {
16476 return qe_invalid;
16477 }
16478 1085280 }
16479
16480
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 1085280 times.
1266160 for(int32_t k=0; k<6; k++)
16481 {
16482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16483 {
16484 return qe_invalid;
16485 }
16486 1085280 }
16487 180880 }
16488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16489 {
16490 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16491 {
16492 return qe_invalid;
16493 }
16494
16495 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16496 {
16497 return qe_invalid;
16498 }
16499
16500 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16501 {
16502 return qe_invalid;
16503 }
16504
16505 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16506
16507 {
16508 return qe_invalid;
16509 }
16510 }
16511
16512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>149))
16513 {
16514 for(int32_t k=0; k<6; k++)
16515 {
16516 if(!p_getc(&tempbyte,f,true)) //layerxsize
16517 {
16518 return qe_invalid;
16519 }
16520 }
16521
16522 for(int32_t k=0; k<6; k++)
16523 {
16524 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16525 {
16526 return qe_invalid;
16527 }
16528 }
16529
16530 for(int32_t k=0; k<6; k++)
16531 {
16532 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16533 {
16534 return qe_invalid;
16535 }
16536 }
16537
16538 for(int32_t k=0; k<6; k++)
16539 {
16540 if(!p_getc(&tempbyte,f,true)) //layerysize
16541 {
16542 return qe_invalid;
16543 }
16544 }
16545
16546 for(int32_t k=0; k<6; k++)
16547 {
16548 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16549 {
16550 return qe_invalid;
16551 }
16552 }
16553
16554 for(int32_t k=0; k<6; k++)
16555 {
16556 if(!p_getc(&tempbyte,f,true)) //layerydelay
16557 {
16558 return qe_invalid;
16559 }
16560 }
16561 }
16562
16563
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16564 {
16565
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16566 {
16567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16568 {
16569 return qe_invalid;
16570 }
16571 1085280 }
16572 180880 }
16573
16574
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16575 {
16576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 if((Header->zelda_version == 0x192)&&(Header->build>153))
16577 {
16578 if(!p_getc(&padding,f,true))
16579 {
16580 return qe_invalid;
16581 }
16582 }
16583
16584
1/2
✓ Branch 0 taken 180880 times.
✗ Branch 1 not taken.
180880 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16585 {
16586 return qe_invalid;
16587 }
16588 180880 }
16589
16590
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16591 {
16592 6864 extras=15;
16593 6864 }
16594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16595 {
16596 extras=11;
16597 }
16598
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16599 {
16600 extras=32;
16601 }
16602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16603 {
16604 extras=64;
16605 }
16606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 else if(Header->zelda_version < 0x193)
16607 {
16608 extras=62;
16609 }
16610 else
16611
16612 {
16613 180880 extras=0;
16614 }
16615
16616
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 187744 times.
290704 for(int32_t k=0; k<extras; k++)
16617 {
16618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16619 {
16620 return qe_invalid;
16621 }
16622 102960 }
16623
16624
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16625 //if (version>3)
16626 {
16627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16628 {
16629 return qe_invalid;
16630 }
16631
16632
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16633 {
16634 return qe_invalid;
16635 }
16636 153000 }
16637 else
16638 {
16639 34744 temp_mapscr->nextmap=0;
16640 34744 temp_mapscr->nextscr=0;
16641 }
16642
16643
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16644 {
16645 6864 secretcombos=20;
16646 6864 }
16647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16648 {
16649 secretcombos=256;
16650 }
16651 else
16652 {
16653 180880 secretcombos=128;
16654 }
16655
16656
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16657 {
16658
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16659 {
16660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16661 {
16662 return qe_invalid;
16663 }
16664
16665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16666 {
16667 137280 temp_mapscr->secretcombo[k]=tempbyte;
16668 137280 }
16669 137280 }
16670 6864 }
16671 else
16672 {
16673
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16674 {
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16676 {
16677 return qe_invalid;
16678 }
16679
16680 23152640 }
16681 }
16682
16683
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16684 {
16685
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16686 {
16687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16688 {
16689 return qe_invalid;
16690 }
16691 23152640 }
16692
16693
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16694 {
16695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16696 {
16697 return qe_invalid;
16698 }
16699 23152640 }
16700 180880 }
16701
16702
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16703 {
16704 if(!p_getc(&padding,f,true))
16705 {
16706 return qe_invalid;
16707 }
16708 }
16709
16710 187744 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16711
16712
2/2
✓ Branch 0 taken 33042944 times.
✓ Branch 1 taken 187744 times.
33230688 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16713 {
16714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33042944 times.
33042944 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16715 {
16716 return qe_invalid;
16717 }
16718 33042944 }
16719
16720
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16721 {
16722 if(!p_getc(&padding,f,true))
16723 {
16724 return qe_invalid;
16725 }
16726
16727 if(!p_getc(&padding,f,true))
16728 {
16729 return qe_invalid;
16730 }
16731 }
16732
16733
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16734 {
16735
2/2
✓ Branch 0 taken 31834880 times.
✓ Branch 1 taken 180880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16736 {
16737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16738 {
16739 return qe_invalid;
16740 }
16741
16742
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31834880 if((Header->zelda_version == 0x192)&&(Header->build<24))
16743 {
16744 if(!p_getc(&tempbyte,f,true))
16745 {
16746 return qe_invalid;
16747 }
16748
16749 if(!p_getc(&tempbyte,f,true))
16750 {
16751 return qe_invalid;
16752 }
16753
16754 if(!p_getc(&tempbyte,f,true))
16755 {
16756 return qe_invalid;
16757 }
16758 }
16759 31834880 }
16760 180880 }
16761
16762
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16763 {
16764
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 31834880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16765 {
16766
16767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16768 {
16769 return qe_invalid;
16770 }
16771 31834880 }
16772 180880 }
16773
16774
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16775 {
16776 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16777 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16778 6864 }
16779
16780
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16781 {
16782 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16783 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16784 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16785 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16786 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16787 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16788 6864 }
16789
16790
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16791 {
16792
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16793 {
16794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16795 {
16796 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16797 {
16798 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16799 }
16800 }
16801 else
16802 {
16803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16804 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16805 {
16806 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16807 1208064 }
16808
16809 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16810 }
16811
16812 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16813 1208064 }
16814 6864 }
16815
16816 /*if(version>12)
16817 {
16818 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16819 {
16820 return qe_invalid;
16821 }
16822 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16823 {
16824 return qe_invalid;
16825 }
16826 }*/
16827
16828
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>4)
16829 {
16830
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16831 {
16832 return qe_invalid;
16833 }
16834 153000 }
16835 else
16836 {
16837 34744 temp_mapscr->screen_midi = -1;
16838 }
16839
16840
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>=17)
16841 {
16842
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16843 {
16844 return qe_invalid;
16845 }
16846 153000 }
16847 else
16848 {
16849 34744 temp_mapscr->lens_layer = llNORMAL;
16850 }
16851
16852
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version>6)
16853 {
16854 dword bits;
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_igetl(&bits,f,true))
16856 {
16857 return qe_invalid;
16858 }
16859
16860 int32_t m;
16861 float tempfloat;
16862 word tempw;
16863 153000 temp_mapscr->ffcCountMarkDirty();
16864
16865
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 4896000 times.
5049000 for(m=0; m<32; m++)
16866 {
16867 4896000 ffcdata& tempffc = temp_mapscr->ffcs[m];
16868 4896000 tempffc.clear();
16869
2/2
✓ Branch 0 taken 4873014 times.
✓ Branch 1 taken 22986 times.
4896000 if((bits>>m)&1)
16870 {
16871
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetw(&tempw,f,true))
16872 {
16873 return qe_invalid;
16874 }
16875 22986 tempffc.setData(tempw);
16876
16877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.cset),f,true))
16878 {
16879 return qe_invalid;
16880 }
16881
16882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.delay),f,true))
16883 {
16884 return qe_invalid;
16885 }
16886
16887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(version < 9)
16888 {
16889 if(!p_igetf(&tempfloat,f,true))
16890 {
16891 return qe_invalid;
16892 }
16893
16894 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16895
16896 if(!p_igetf(&tempfloat,f,true))
16897 {
16898 return qe_invalid;
16899 }
16900
16901 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16902
16903 if(!p_igetf(&tempfloat,f,true))
16904 {
16905 return qe_invalid;
16906 }
16907
16908 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16909
16910 if(!p_igetf(&tempfloat,f,true))
16911 {
16912 return qe_invalid;
16913 }
16914
16915 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16916
16917 if(!p_igetf(&tempfloat,f,true))
16918 {
16919 return qe_invalid;
16920 }
16921
16922 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16923
16924 if(!p_igetf(&tempfloat,f,true))
16925 {
16926 return qe_invalid;
16927 }
16928
16929 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16930 }
16931 else
16932 {
16933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.x),f,true))
16934 {
16935 return qe_invalid;
16936 }
16937
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.y),f,true))
16939 {
16940 return qe_invalid;
16941 }
16942
16943
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetzf(&(tempffc.vx),f,true))
16944 {
16945 return qe_invalid;
16946 }
16947
16948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.vy),f,true))
16949 {
16950 return qe_invalid;
16951 }
16952
16953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ax),f,true))
16954 {
16955 return qe_invalid;
16956 }
16957
16958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ay),f,true))
16959 {
16960 return qe_invalid;
16961 }
16962 }
16963
16964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.link),f,true))
16965 {
16966 return qe_invalid;
16967 }
16968
16969
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>7)
16970 {
16971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16972 {
16973 return qe_invalid;
16974 }
16975
16976 22986 tempffc.hit_width = (tempbyte&0x3F)+1;
16977 22986 tempffc.txsz = (tempbyte>>6)+1;
16978
16979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16980 {
16981 return qe_invalid;
16982 }
16983
16984 22986 tempffc.hit_height = (tempbyte&0x3F)+1;
16985 22986 tempffc.tysz = (tempbyte>>6)+1;
16986
16987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.flags),f,true))
16988 {
16989 return qe_invalid;
16990 }
16991 22986 }
16992 else
16993 {
16994 tempffc.hit_width=16;
16995 tempffc.hit_height=16;
16996 tempffc.txsz=1;
16997 tempffc.tysz=1;
16998 tempffc.flags=0;
16999 }
17000
17001 22986 tempffc.updateSolid();
17002
17003
17004
4/6
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20966 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20966 times.
22986 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
17005 {
17006 tempffc.flags|=ffIGNOREHOLDUP;
17007 }
17008
17009
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>9)
17010 {
17011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.script),f,true))
17012 {
17013 return qe_invalid;
17014 }
17015 22986 }
17016 else
17017 {
17018 tempffc.script=0;
17019 }
17020
17021
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>10)
17022 {
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[0]),f,true))
17024 {
17025 return qe_invalid;
17026 }
17027
17028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[1]),f,true))
17029 {
17030 return qe_invalid;
17031 }
17032
17033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[2]),f,true))
17034 {
17035 return qe_invalid;
17036 }
17037
17038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[3]),f,true))
17039 {
17040 return qe_invalid;
17041 }
17042
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[4]),f,true))
17044 {
17045 return qe_invalid;
17046 }
17047
17048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[5]),f,true))
17049 {
17050 return qe_invalid;
17051 }
17052
17053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[6]),f,true))
17054 {
17055 return qe_invalid;
17056 }
17057
17058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[7]),f,true))
17059 {
17060 return qe_invalid;
17061 }
17062
17063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
17064 {
17065 return qe_invalid;
17066 }
17067
17068 22986 tempffc.inita[0]=tempbyte*10000;
17069
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
17071 {
17072 return qe_invalid;
17073 }
17074
17075 22986 tempffc.inita[1]=tempbyte*10000;
17076 22986 }
17077 else
17078 {
17079 tempffc.inita[0] = 10000;
17080 tempffc.inita[1] = 10000;
17081 }
17082
17083
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version <= 11)
17084 {
17085 fixffcs=true;
17086 }
17087 22986 }
17088 4896000 }
17089
17090 153000 }
17091
17092 //add in the new whistle flags
17093
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version<13)
17094 {
17095
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
17096 {
17097 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
17098 12 }
17099 34744 }
17100
17101 //2.55 starts here
17102
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 19 && Header->zelda_version > 0x253 )
17103 {
17104
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17105 {
17106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17107 {
17108 return qe_invalid;
17109 }
17110 137360 }
17111
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17112 {
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17114 {
17115 return qe_invalid;
17116 }
17117 137360 }
17118
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17121 {
17122 return qe_invalid;
17123 }
17124 137360 }
17125
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17126 {
17127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17128 {
17129 return qe_invalid;
17130 }
17131 137360 }
17132 13736 }
17133
3/4
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 174008 times.
187744 if ( version < 19 && Header->zelda_version > 0x253 )
17134 {
17135 for ( int32_t q = 0; q < 10; q++ )
17136 {
17137 temp_mapscr->npcstrings[q] = 0;
17138 temp_mapscr->new_items[q] = 0;
17139 temp_mapscr->new_item_x[q] = 0;
17140 temp_mapscr->new_item_y[q] = 0;
17141 }
17142 }
17143
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 20 && Header->zelda_version > 0x253 )
17144 {
17145
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17146 {
17147 return qe_invalid;
17148 }
17149
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17150 {
17151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17152 {
17153 return qe_invalid;
17154 }
17155 109888 }
17156 13736 }
17157
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
187744 if ( version < 20 )
17158 {
17159 174008 temp_mapscr->script = 0;
17160
2/2
✓ Branch 0 taken 1392064 times.
✓ Branch 1 taken 174008 times.
1566072 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17161 174008 }
17162
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 21 && Header->zelda_version > 0x253 )
17163 {
17164
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17165 {
17166 return qe_invalid;
17167 }
17168 13736 }
17169
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 21 )
17170 {
17171 174008 temp_mapscr->preloadscript = 0;
17172 174008 }
17173 //all builds with version > 20 need this. -Z
17174
17175
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17176 {
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17178 {
17179 return qe_invalid;
17180 }
17181
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17182 {
17183 return qe_invalid;
17184 }
17185 13736 }
17186
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 22 )
17187 {
17188 174008 temp_mapscr->hidelayers = 0;
17189 174008 temp_mapscr->hidescriptlayers = 0;
17190 174008 }
17191
17192 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17193 //May be any version before 2.11. -Z
17194 /* --not the roar, the HIT SFX
17195 if ( Header->zelda_version <= 0x210 )
17196 {
17197 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17198 {
17199 temp_mapscr->bosssfx = WAV_ROAR;
17200 }
17201 }
17202 */
17203
17204 187744 return 0;
17205 187744 }
17206 202568 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17207 {
17208
2/2
✓ Branch 0 taken 187744 times.
✓ Branch 1 taken 14824 times.
202568 if(version < 23)
17209 {
17210 187744 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17211
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(ret) return ret;
17212 187744 }
17213 else
17214 {
17215
1/2
✓ Branch 0 taken 14824 times.
✗ Branch 1 not taken.
14824 if(!p_getc(&(temp_mapscr->valid),f,true))
17216 return qe_invalid;
17217
2/2
✓ Branch 0 taken 5753 times.
✓ Branch 1 taken 9071 times.
14824 if(!(temp_mapscr->valid & mVALID))
17218 9071 return 0; //Empty screen
17219 uint32_t scr_has_flags;
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(!p_igetl(&scr_has_flags,f,true))
17221 return qe_invalid;
17222
17223
2/2
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 60 times.
5753 if(scr_has_flags & SCRHAS_ROOMDATA)
17224 {
17225
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&(temp_mapscr->guy),f,true))
17226 return qe_invalid;
17227
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->str),f,true))
17228 return qe_invalid;
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!p_getc(&(temp_mapscr->room),f,true))
17230 return qe_invalid;
17231
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17232 return qe_invalid;
17233 60 }
17234
2/2
✓ Branch 0 taken 5642 times.
✓ Branch 1 taken 111 times.
5753 if(scr_has_flags & SCRHAS_ITEM)
17235 {
17236
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&(temp_mapscr->item),f,true))
17237 return qe_invalid;
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17239 return qe_invalid;
17240
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&(temp_mapscr->itemx),f,true))
17241 return qe_invalid;
17242
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&(temp_mapscr->itemy),f,true))
17243 return qe_invalid;
17244 111 }
17245
2/2
✓ Branch 0 taken 5415 times.
✓ Branch 1 taken 338 times.
5753 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17246 {
17247
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17248 return qe_invalid;
17249 338 }
17250
2/2
✓ Branch 0 taken 5528 times.
✓ Branch 1 taken 225 times.
5753 if(scr_has_flags & SCRHAS_TWARP)
17251 {
17252
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17253 {
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17255 return qe_invalid;
17256 900 }
17257
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17258 {
17259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17260 return qe_invalid;
17261 900 }
17262
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17263 {
17264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17265 return qe_invalid;
17266 900 }
17267
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17268 return qe_invalid;
17269 225 }
17270
2/2
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 139 times.
5753 if(scr_has_flags & SCRHAS_SWARP)
17271 {
17272
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17273 {
17274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17275 return qe_invalid;
17276 556 }
17277
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17278 {
17279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17280 return qe_invalid;
17281 556 }
17282
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17283 {
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17285 return qe_invalid;
17286 556 }
17287
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17288 return qe_invalid;
17289
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17290 return qe_invalid;
17291 139 }
17292
2/2
✓ Branch 0 taken 5411 times.
✓ Branch 1 taken 342 times.
5753 if(scr_has_flags & SCRHAS_WARPRET)
17293 {
17294
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17295 {
17296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17297 return qe_invalid;
17298 1368 }
17299
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17300 {
17301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17302 return qe_invalid;
17303 1368 }
17304
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17305 return qe_invalid;
17306
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17307 return qe_invalid;
17308 342 }
17309
2/2
✓ Branch 0 taken 1116 times.
✓ Branch 1 taken 4637 times.
5753 if(scr_has_flags & SCRHAS_LAYERS)
17310 {
17311
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17312 {
17313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17314 return qe_invalid;
17315 6696 }
17316
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17317 {
17318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17319 return qe_invalid;
17320 6696 }
17321
2/2
✓ Branch 0 taken 6696 times.
✓ Branch 1 taken 1116 times.
7812 for(int32_t k=0; k<6; k++)
17322 {
17323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6696 times.
6696 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17324 return qe_invalid;
17325 6696 }
17326
1/2
✓ Branch 0 taken 1116 times.
✗ Branch 1 not taken.
1116 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17327 return qe_invalid;
17328
1/2
✓ Branch 0 taken 1116 times.
✗ Branch 1 not taken.
1116 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17329 return qe_invalid;
17330 1116 }
17331 else
17332 {
17333
2/2
✓ Branch 0 taken 27822 times.
✓ Branch 1 taken 4637 times.
32459 for(int32_t k=0; k<6; k++)
17334 {
17335 27822 temp_mapscr->layeropacity[k] = 255;
17336 27822 }
17337 }
17338
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_MAZE)
17339 {
17340 for(int32_t k=0; k<4; k++)
17341 {
17342 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17343 return qe_invalid;
17344 }
17345 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17346 return qe_invalid;
17347 }
17348
2/2
✓ Branch 0 taken 5620 times.
✓ Branch 1 taken 133 times.
5753 if(scr_has_flags & SCRHAS_D_S_U)
17349 {
17350
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17351 return qe_invalid;
17352
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 133 times.
665 for(int32_t k=0; k<4; k++)
17353 {
17354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17355 return qe_invalid;
17356 532 }
17357
17358
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&(temp_mapscr->stairx),f,true))
17359 return qe_invalid;
17360
17361
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&(temp_mapscr->stairy),f,true))
17362 return qe_invalid;
17363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17364 return qe_invalid;
17365
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&(temp_mapscr->undercset),f,true))
17366 return qe_invalid;
17367 133 }
17368
2/2
✓ Branch 0 taken 5348 times.
✓ Branch 1 taken 405 times.
5753 if(scr_has_flags & SCRHAS_FLAGS)
17369 {
17370
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags),f,true))
17371 return qe_invalid;
17372
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags2),f,true))
17373 return qe_invalid;
17374
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags3),f,true))
17375 return qe_invalid;
17376
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags4),f,true))
17377 return qe_invalid;
17378
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags5),f,true))
17379 return qe_invalid;
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->flags6),f,true))
17381 return qe_invalid;
17382
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags7),f,true))
17383 return qe_invalid;
17384
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags8),f,true))
17385 return qe_invalid;
17386
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags9),f,true))
17387 return qe_invalid;
17388
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->flags10),f,true))
17389 return qe_invalid;
17390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17391 return qe_invalid;
17392 405 }
17393
2/2
✓ Branch 0 taken 5386 times.
✓ Branch 1 taken 367 times.
5753 if(scr_has_flags & SCRHAS_ENEMY)
17394 {
17395
2/2
✓ Branch 0 taken 3670 times.
✓ Branch 1 taken 367 times.
4037 for(int32_t k=0; k<10; k++)
17396 {
17397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3670 times.
3670 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17398 return qe_invalid;
17399
1/2
✓ Branch 0 taken 3670 times.
✗ Branch 1 not taken.
3670 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17400 temp_mapscr->enemy[k] = 0;
17401 3670 }
17402
1/2
✓ Branch 0 taken 367 times.
✗ Branch 1 not taken.
367 if(!p_getc(&(temp_mapscr->pattern),f,true))
17403 return qe_invalid;
17404 367 }
17405
2/2
✓ Branch 0 taken 5720 times.
✓ Branch 1 taken 33 times.
5753 if(scr_has_flags & SCRHAS_CARRY)
17406 {
17407
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17408 return qe_invalid;
17409
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17410 return qe_invalid;
17411
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17412 return qe_invalid;
17413
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17414 return qe_invalid;
17415 33 }
17416
2/2
✓ Branch 0 taken 5722 times.
✓ Branch 1 taken 31 times.
5753 if(scr_has_flags & SCRHAS_SCRIPT)
17417 {
17418
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->script),f,true))
17419 return qe_invalid;
17420
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17421 return qe_invalid;
17422
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
279 for ( int32_t q = 0; q < 8; q++ )
17423 {
17424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17425 return qe_invalid;
17426 248 }
17427 31 }
17428
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_UNUSED)
17429 {
17430 for ( int32_t q = 0; q < 10; q++ )
17431 {
17432 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17433 return qe_invalid;
17434 }
17435 for ( int32_t q = 0; q < 10; q++ )
17436 {
17437 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17438 return qe_invalid;
17439 }
17440 for ( int32_t q = 0; q < 10; q++ )
17441 {
17442 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17443 return qe_invalid;
17444 }
17445 for ( int32_t q = 0; q < 10; q++ )
17446 {
17447 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17448 return qe_invalid;
17449 }
17450 }
17451
2/2
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 397 times.
5753 if(scr_has_flags & SCRHAS_SECRETS)
17452 {
17453
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17454 {
17455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17456 return qe_invalid;
17457 50816 }
17458
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17459 {
17460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17461 return qe_invalid;
17462 50816 }
17463
2/2
✓ Branch 0 taken 50816 times.
✓ Branch 1 taken 397 times.
51213 for(int32_t k=0; k<128; k++)
17464 {
17465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50816 times.
50816 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17466 return qe_invalid;
17467 50816 }
17468 397 }
17469
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2808 times.
5753 if(scr_has_flags & SCRHAS_COMBOFLAG)
17470 {
17471
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17472 {
17473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17474 return qe_invalid;
17475 494208 }
17476
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17477 {
17478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17479 return qe_invalid;
17480 494208 }
17481
2/2
✓ Branch 0 taken 494208 times.
✓ Branch 1 taken 2808 times.
497016 for(int32_t k=0; k<176; ++k)
17482 {
17483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494208 times.
494208 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17484 return qe_invalid;
17485 494208 }
17486 2808 }
17487
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(scr_has_flags & SCRHAS_MISC)
17488 {
17489
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&(temp_mapscr->color),f,true))
17490 return qe_invalid;
17491
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17492 return qe_invalid;
17493
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17494 return qe_invalid;
17495
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17496 return qe_invalid;
17497
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17498 return qe_invalid;
17499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17500 return qe_invalid;
17501
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17502 return qe_invalid;
17503
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17504 return qe_invalid;
17505
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17506 return qe_invalid;
17507 5753 }
17508 else
17509 {
17510 temp_mapscr->screen_midi = -1;
17511 temp_mapscr->csensitive = 1;
17512 }
17513 //FFC
17514 5753 bool old_ff = version < 25;
17515 5753 dword bits = 0;
17516 5753 word numffc = 32;
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5753 times.
5753 if(old_ff)
17518 {
17519 if(!p_igetl(&bits,f,true))
17520 return qe_invalid;
17521 }
17522 else
17523 {
17524
1/2
✓ Branch 0 taken 5753 times.
✗ Branch 1 not taken.
5753 if(!p_igetw(&numffc,f,true))
17525 return qe_invalid;
17526 }
17527 byte tempbyte;
17528 word tempw;
17529
4/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5726 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27 times.
5753 static ffcdata nil_ffc;
17530 5753 temp_mapscr->ffcCountMarkDirty();
17531
2/2
✓ Branch 0 taken 5753 times.
✓ Branch 1 taken 7870 times.
13623 for(word m = 0; m < numffc; ++m)
17532 {
17533
1/2
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
7870 ffcdata& tempffc = (m < MAXFFCS)
17534 7870 ? temp_mapscr->ffcs[m]
17535 : nil_ffc; //sanity
17536 7870 tempffc.clear();
17537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7870 if(old_ff && !(bits & (1<<m))) continue;
17538
17539
1/2
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
7870 if(!p_igetw(&tempw,f,true))
17540 return qe_invalid;
17541
3/4
✓ Branch 0 taken 7870 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 6498 times.
7870 if(!old_ff && !tempw) //empty ffc, nothing more to load
17542 6498 continue;
17543 1372 tempffc.setData(tempw);
17544
17545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.cset),f,true))
17546 return qe_invalid;
17547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetw(&(tempffc.delay),f,true))
17548 return qe_invalid;
17549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.x),f,true))
17550 return qe_invalid;
17551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.y),f,true))
17552 return qe_invalid;
17553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.vx),f,true))
17554 return qe_invalid;
17555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetzf(&(tempffc.vy),f,true))
17556 return qe_invalid;
17557
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetzf(&(tempffc.ax),f,true))
17558 return qe_invalid;
17559
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetzf(&(tempffc.ay),f,true))
17560 return qe_invalid;
17561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.link),f,true))
17562 return qe_invalid;
17563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(version < 24)
17564 {
17565 if(!p_getc(&tempbyte,f,true))
17566 return qe_invalid;
17567 tempffc.hit_width = (tempbyte&0x3F)+1;
17568 tempffc.txsz = (tempbyte>>6)+1;
17569 if(!p_getc(&tempbyte,f,true))
17570 return qe_invalid;
17571 tempffc.hit_height = (tempbyte&0x3F)+1;
17572 tempffc.tysz = (tempbyte>>6)+1;
17573 }
17574 else
17575 {
17576
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetl(&(tempffc.hit_width),f,true))
17577 return qe_invalid;
17578
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_igetl(&(tempffc.hit_height),f,true))
17579 return qe_invalid;
17580
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_getc(&(tempffc.txsz),f,true))
17581 return qe_invalid;
17582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempffc.tysz),f,true))
17583 return qe_invalid;
17584 }
17585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetl(&(tempffc.flags),f,true))
17586 return qe_invalid;
17587 1372 tempffc.updateSolid();
17588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_igetw(&(tempffc.script),f,true))
17589 return qe_invalid;
17590
2/2
✓ Branch 0 taken 10976 times.
✓ Branch 1 taken 1372 times.
12348 for(auto q = 0; q < 8; ++q)
17591 {
17592
1/2
✓ Branch 0 taken 10976 times.
✗ Branch 1 not taken.
10976 if(!p_igetl(&(tempffc.initd[q]),f,true))
17593 return qe_invalid;
17594 10976 }
17595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372 times.
1372 if(!p_getc(&(tempbyte),f,true))
17596 return qe_invalid;
17597 1372 tempffc.inita[0]=tempbyte*10000;
17598
17599
1/2
✓ Branch 0 taken 1372 times.
✗ Branch 1 not taken.
1372 if(!p_getc(&(tempbyte),f,true))
17600 return qe_invalid;
17601 1372 tempffc.inita[1]=tempbyte*10000;
17602 1372 }
17603
2/2
✓ Branch 0 taken 728514 times.
✓ Branch 1 taken 5753 times.
734267 for(word m = numffc; m < MAXFFCS; ++m)
17604 {
17605 728514 temp_mapscr->ffcs[m].clear();
17606 728514 }
17607 //END FFC
17608 }
17609 193497 return 0;
17610 202568 }
17611
17612
17613 115 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17614 {
17615 115 int32_t scr=0;
17616
17617 115 word version=0;
17618 dword dummy;
17619 int32_t screens_to_read;
17620
17621 115 mapscr temp_mapscr;
17622 zcmap temp_map;
17623 word temp_map_count;
17624 dword section_size;
17625
17626
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17627 {
17628 4 screens_to_read=MAPSCRS192b136;
17629 4 }
17630 else
17631 {
17632 111 screens_to_read=MAPSCRS;
17633 }
17634
17635
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(Header->zelda_version > 0x192)
17636 {
17637 //section version info
17638
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&version,f,true))
17639 {
17640 return qe_invalid;
17641 }
17642
17643 111 FFCore.quest_format[vMaps] = version;
17644
17645 //al_trace("Maps version %d\n", version);
17646
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy,f,true))
17647 {
17648 return qe_invalid;
17649 }
17650
17651 //section size
17652
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&section_size,f,true))
17653 {
17654 return qe_invalid;
17655 }
17656
17657 //finally... section data
17658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_igetw(&temp_map_count,f,true))
17659 {
17660 return 5;
17661 }
17662 111 }
17663 else
17664 {
17665 4 temp_map_count=map_count;
17666 }
17667
17668
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17669 {
17670 return qe_invalid;
17671 }
17672
17673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata)
17674 {
17675 115 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17676 115 TheMaps.resize(_mapsSize);
17677
17678
2/2
✓ Branch 0 taken 203728 times.
✓ Branch 1 taken 115 times.
203843 for(int32_t i(0); i<_mapsSize; i++)
17679 203728 TheMaps[i].zero_memory();
17680
17681 115 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17682 115 }
17683
17684 115 temp_mapscr.zero_memory();
17685
17686 115 memset(&temp_map, 0, sizeof(zcmap));
17687 115 temp_map.scrResWidth = 256;
17688 115 temp_map.scrResHeight = 224;
17689 115 temp_map.tileWidth = 16;
17690 115 temp_map.tileHeight = 11;
17691 115 temp_map.viewWidth = 256;
17692 115 temp_map.viewHeight = 176;
17693 115 temp_map.viewX = 0;
17694 115 temp_map.viewY = 64;
17695 115 temp_map.subaWidth = 256;
17696 115 temp_map.subaHeight = 168;
17697 115 temp_map.subaTrans = false;
17698 115 temp_map.subpWidth = 256;
17699 115 temp_map.subpHeight = 56;
17700 115 temp_map.subpTrans = false;
17701
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1498 times.
✓ Branch 2 taken 1498 times.
✓ Branch 3 taken 115 times.
1613 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17702 {
17703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1498 times.
1498 if(keepdata==true) //!TODO Trim fully
17704 {
17705 1498 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17706 1498 }
17707 1498 byte valid=1;
17708
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 116 times.
1498 if(version > 22)
17709 {
17710
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&valid,f,true))
17711 return qe_invalid;
17712 116 }
17713
2/2
✓ Branch 0 taken 203520 times.
✓ Branch 1 taken 1498 times.
205018 for(int32_t j=0; j<screens_to_read; j++)
17714 {
17715 203520 scr=i*MAPSCRS+j;
17716 203520 clear_screen(&temp_mapscr);
17717
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 202568 times.
203520 if(valid)
17718 202568 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17719
17720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203520 times.
203520 if(keepdata==true)
17721 {
17722 203520 TheMaps[scr] = temp_mapscr;
17723 203520 }
17724 203520 }
17725
17726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1498 times.
1498 if(keepdata==true)
17727 {
17728
3/6
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1446 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1498 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17729 {
17730 52 int32_t index = (i*MAPSCRS+132);
17731
17732 52 TheMaps[index]=TheMaps[index-1];
17733
17734 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17735 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17736 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17737
17738
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17739 {
17740 156 scr=i*MAPSCRS+j;
17741
17742 156 TheMaps[scr].zero_memory();
17743 156 TheMaps[scr].valid = mVERSION;
17744 156 TheMaps[scr].screen_midi = -1;
17745 156 TheMaps[scr].csensitive = 1;
17746 156 }
17747 52 }
17748
17749
3/6
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1446 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1498 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17750 {
17751
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17752 {
17753 7072 scr=i*MAPSCRS+j;
17754 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17755
17756
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17757 {
17758 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17759 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17760 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17761 905216 }
17762 7072 }
17763 52 }
17764 1498 }
17765 1498 }
17766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata)
17767 {
17768 115 map_count = temp_map_count;
17769 115 }
17770 115 clear_screen(&temp_mapscr);
17771 115 return 0;
17772 115 }
17773
17774
17775 706813 void update_combo(newcombo& cmb, word section_version)
17776 {
17777
2/2
✓ Branch 0 taken 122976 times.
✓ Branch 1 taken 583837 times.
706813 if(section_version < 40)
17778 {
17779
3/3
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 11056 times.
✓ Branch 2 taken 571427 times.
583837 switch(cmb.type)
17780 {
17781 case cWATER: case cSHALLOWWATER:
17782 11056 cmb.attribytes[6] = iwRipples;
17783 11056 break;
17784 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17785 1354 cmb.attribytes[6] = iwTallGrass;
17786 1354 break;
17787 }
17788 583837 }
17789 706813 }
17790 87 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17791 {
17792 87 reset_combo_animations();
17793 87 reset_combo_animations2();
17794
17795 87 init_combo_classes();
17796
17797 // combos
17798 87 word combos_used=0;
17799 int32_t dummy;
17800 byte padding;
17801 87 newcombo temp_combo;
17802 //word section_cversion=0;
17803
17804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata==true)
17805 {
17806
2/2
✓ Branch 0 taken 5679360 times.
✓ Branch 1 taken 87 times.
5679447 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17807
1/2
✓ Branch 0 taken 5679360 times.
✗ Branch 1 not taken.
5679360 combobuf[q].clear();
17808 87 }
17809
17810 // if(version > 0x192)
17811 // {
17812 // //section version info
17813 // if(!p_igetw(&section_version,f,true))
17814 // {
17815 // return qe_invalid;
17816 // }
17817
17818 // FFCore.quest_format[vCombos] = section_version;
17819
17820 // //al_trace("Combos version %d\n", section_version);
17821 // if(!p_igetw(&section_cversion,f,true))
17822 // {
17823 // return qe_invalid;
17824 // }
17825
17826 // //section size
17827 // if(!p_igetl(&dummy,f,true))
17828 // {
17829 // return qe_invalid;
17830 // }
17831 // }
17832
17833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(version < 0x174)
17834 {
17835 combos_used=1024;
17836 }
17837
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
87 else if(version < 0x191)
17838 {
17839 4 combos_used=2048;
17840 4 }
17841 else
17842 {
17843
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&combos_used,f,true))
17844 {
17845 return qe_invalid;
17846 }
17847 }
17848
17849 //finally... section data
17850
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 516329 times.
516416 for(int32_t i=0; i<combos_used; i++)
17851 {
17852
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 temp_combo.clear();
17853
17854
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if ( section_version >= 11 )
17855 {
17856
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17857 {
17858 return qe_invalid;
17859 }
17860 68884 }
17861 else
17862 {
17863
2/4
✓ Branch 0 taken 447445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447445 times.
✗ Branch 3 not taken.
447445 if(!p_igetw(&temp_combo.tile,f,true))
17864 {
17865 return qe_invalid;
17866 }
17867 }
17868 516329 temp_combo.o_tile = temp_combo.tile;
17869
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.flip,f,true))
17870 {
17871 return qe_invalid;
17872 }
17873
17874
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.walk,f,true))
17875 {
17876 return qe_invalid;
17877 }
17878
17879
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.type,f,true))
17880 {
17881 return qe_invalid;
17882 }
17883
17884
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.csets,f,true))
17885 {
17886 return qe_invalid;
17887 }
17888
17889
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 508137 times.
516329 if(version < 0x193)
17890 {
17891
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17892 return qe_invalid;
17893
17894
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17895 return qe_invalid;
17896
17897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17898 {
17899
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17900 {
17901 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17902 {
17903 if(!p_getc(&padding,f,true))
17904 return qe_invalid;
17905 }
17906 }
17907 8192 }
17908 8192 }
17909
2/2
✓ Branch 0 taken 508137 times.
✓ Branch 1 taken 8192 times.
516329 if(version >= 0x192)
17910 {
17911
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.frames,f,true))
17912 return qe_invalid;
17913
17914
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.speed,f,true))
17915 return qe_invalid;
17916
17917
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_igetw(&temp_combo.nextcombo,f,true))
17918 return qe_invalid;
17919
17920
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.nextcset,f,true))
17921 return qe_invalid;
17922
17923 //Base flag
17924
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=3)
17925
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.flag,f,true))
17926 return qe_invalid;
17927
17928
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=4)
17929 {
17930
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanim,f,true))
17931 return qe_invalid;
17932
17933
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_igetw(&temp_combo.nexttimer,f,true))
17934 return qe_invalid;
17935 399023 }
17936
17937
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=5)
17938
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanimy,f,true))
17939 return qe_invalid;
17940
17941
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=6)
17942 {
17943
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.animflags,f,true))
17944 return qe_invalid;
17945
17946
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(section_version == 6)
17947 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17948 399023 }
17949
17950
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=8) //combo Attributes[4] and userflags.
17951 {
17952
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17953
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17954 return qe_invalid;
17955
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17956 return qe_invalid;
17957
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17958
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17959 return qe_invalid;
17960 68884 }
17961
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=10) //combo trigger flags
17962 {
17963
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17964
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17965 return qe_invalid;
17966 68884 }
17967
1/2
✓ Branch 0 taken 439253 times.
✗ Branch 1 not taken.
439253 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17968 {
17969 for ( int32_t q = 0; q < 2; q++ )
17970 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17971 return qe_invalid;
17972 }
17973
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 9)
17974
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17975 return qe_invalid;
17976
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 22)
17977
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17978 return qe_invalid;
17979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 24)
17980 {
17981 if(!p_getc(&temp_combo.triggeritem,f,true))
17982 return qe_invalid;
17983 if(!p_getc(&temp_combo.trigtimer,f,true))
17984 return qe_invalid;
17985 }
17986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 25)
17987 if(!p_getc(&temp_combo.trigsfx,f,true))
17988 return qe_invalid;
17989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 27)
17990 if(!p_igetl(&temp_combo.trigchange,f,true))
17991 return qe_invalid;
17992
17993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 29)
17994 {
17995 if(!p_igetw(&temp_combo.trigprox,f,true))
17996 return qe_invalid;
17997 if(!p_getc(&temp_combo.trigctr,f,true))
17998 return qe_invalid;
17999 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18000 return qe_invalid;
18001 }
18002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 30)
18003 if(!p_getc(&temp_combo.triglbeam,f,true))
18004 return qe_invalid;
18005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 31)
18006 {
18007 if(!p_getc(&temp_combo.trigcschange,f,true))
18008 return qe_invalid;
18009 if(!p_igetw(&temp_combo.spawnitem,f,true))
18010 return qe_invalid;
18011 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18012 return qe_invalid;
18013 if(!p_getc(&temp_combo.exstate,f,true))
18014 return qe_invalid;
18015 if(!p_igetl(&temp_combo.spawnip,f,true))
18016 return qe_invalid;
18017 if(!p_getc(&temp_combo.trigcopycat,f,true))
18018 return qe_invalid;
18019 }
18020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 32)
18021 if(!p_getc(&temp_combo.trigcooldown,f,true))
18022 return qe_invalid;
18023
18024
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=12) //combo label
18025 {
18026 char label[12];
18027 68884 label[11] = '\0';
18028
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
18029
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f,true))
18030 return qe_invalid;
18031
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
18032 68884 }
18033
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=13) //attribytes[4]
18034
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
18035
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
18036 68884 return qe_invalid;
18037 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
18038 * This fixes a poor implementation of a ->next flag bug thing.
18039 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
18040 * there was a version bump a few weeks before a change that broke stuff.
18041 */
18042
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
508137 if (section_version >= 13 && section_version < 21)
18043 {
18044 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
18045 }
18046 //combo scripts
18047
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=14)
18048 {
18049
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
18050 return qe_invalid;
18051
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
18052
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
18053 return qe_invalid;
18054 68884 }
18055 //al_trace("Read combo script data\n");
18056
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=15)
18057 {
18058
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
18059
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
18060
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
18061
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
18062 68884 }
18063
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=17) //attribytes[4]
18064 {
18065
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18066
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
18067 return qe_invalid;
18068
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18069
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18070 return qe_invalid;
18071 68884 }
18072
18073
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(version < 0x193)
18074 for(int32_t q=0; q<11; q++)
18075 if(!p_getc(&dummy,f,true))
18076 return qe_invalid;
18077 508137 }
18078
18079 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18080
3/6
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399023 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516329 if((version < 0x211)||((version == 0x211)&&(build<7)))
18081 {
18082
3/4
✓ Branch 0 taken 117306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109114 times.
✓ Branch 3 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18083 {
18084
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
18085 {
18086 case 130:
18087 temp_combo.tile = 132;
18088 break;
18089
18090 case 131:
18091 temp_combo.tile = 133;
18092 break;
18093
18094 case 132:
18095 temp_combo.tile = 130;
18096 break;
18097
18098 case 133:
18099 temp_combo.tile = 131;
18100 break;
18101 }
18102 8192 }
18103 117306 }
18104
18105
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 15)
18106 447445 temp_combo.o_tile = temp_combo.tile;
18107
18108
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version<18) //upper bits for .walk
18109 447445 temp_combo.walk |= 0xF0;
18110
18111
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 19)
18112
2/2
✓ Branch 0 taken 1789780 times.
✓ Branch 1 taken 447445 times.
2237225 for(int32_t q = 0; q < 4; ++q)
18113 2237225 temp_combo.attributes[q] *= 10000L;
18114
18115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 23)
18116 {
18117
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 515945 times.
516329 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
18118 {
18119 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18120 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18121 case cTRIGGERGENERIC: case cCSWITCH:
18122 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
18123 384 }
18124 516329 }
18125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 25)
18126 {
18127
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 513681 times.
516329 switch(temp_combo.type)
18128 {
18129 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
2648 if(!(temp_combo.usrflags & cflag3))
18131 2648 temp_combo.attribytes[3] = WAV_DOOR;
18132 2648 temp_combo.usrflags &= ~cflag3;
18133 2648 break;
18134 }
18135 516329 }
18136
18137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 26)
18138
2/2
✓ Branch 0 taken 515799 times.
✓ Branch 1 taken 530 times.
516859 if(temp_combo.type == cARMOS)
18139
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if(temp_combo.usrflags & cflag1)
18140 temp_combo.usrflags |= cflag3;
18141
18142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 27)
18143 {
18144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
18145 temp_combo.trigchange = 1;
18146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
18147 temp_combo.trigchange = -1;
18148 516329 else temp_combo.trigchange = 0;
18149 516329 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
18150 516329 }
18151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 28)
18152 {
18153
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 514920 times.
516329 switch(temp_combo.type)
18154 {
18155 case cLOCKBLOCK: case cLOCKEDCHEST:
18156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1409 times.
1409 if(temp_combo.usrflags & cflag7)
18157 temp_combo.usrflags |= cflag8;
18158 1409 else temp_combo.usrflags &= ~cflag8;
18159 1409 temp_combo.usrflags &= ~cflag7;
18160 1409 break;
18161 }
18162
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 516260 times.
516329 switch(temp_combo.type)
18163 {
18164 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18165 69 temp_combo.attrishorts[2] = -1;
18166 69 temp_combo.usrflags |= cflag7;
18167 69 break;
18168 }
18169 516329 }
18170
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 20)
18171 {
18172 447445 temp_combo.genflags = 0;
18173
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 429922 times.
447445 switch(temp_combo.type)
18174 {
18175 case cPUSH_WAIT: case cPUSH_HEAVY:
18176 case cPUSH_HW: case cL_STATUE:
18177 case cR_STATUE: case cPUSH_HEAVY2:
18178 case cPUSH_HW2: case cPOUND:
18179 case cC_STATUE: case cMIRROR:
18180 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18181 case cMAGICPRISM: case cMAGICPRISM4:
18182 case cMAGICSPONGE: case cEYEBALL_A:
18183 case cEYEBALL_B: case cEYEBALL_4:
18184 case cBUSH: case cFLOWERS:
18185 case cLOCKBLOCK: case cLOCKBLOCK2:
18186 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18187 case cCHEST: case cCHEST2:
18188 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18189 case cBOSSCHEST: case cBOSSCHEST2:
18190 case cBUSHNEXT: case cBUSHTOUCHY:
18191 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18192 case cSIGNPOST: case cCSWITCHBLOCK:
18193 case cTORCH: case cTRIGGERGENERIC:
18194
1/2
✓ Branch 0 taken 17523 times.
✗ Branch 1 not taken.
17523 if(temp_combo.usrflags & cflag16)
18195 {
18196 temp_combo.genflags |= cflag1;
18197 temp_combo.usrflags &= ~cflag16;
18198 }
18199 17523 break;
18200 }
18201 447445 }
18202
18203 516329 update_combo(temp_combo, section_version);
18204
18205
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(keepdata==true && i>=start_combo)
18206 {
18207
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 combobuf[i] = temp_combo;
18208 516329 }
18209 516329 }
18210
18211
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(keepdata==true)
18212 {
18213
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18214 {
18215
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18216 {
18217
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18218 {
18219 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18220 }
18221 261120 }
18222 4 }
18223
18224 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18225
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
87 if(version == 0x210 && !is_zquest())
18226 {
18227
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18228
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18229 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18230 5 }
18231
18232
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 9 times.
87 if(section_version<7)
18233 {
18234
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18235 {
18236
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18237 {
18238 case cSLASH:
18239 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18240 61 break;
18241
18242 case cSLASHITEM:
18243 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18244 62 break;
18245
18246 case cBUSH:
18247 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18248 28 break;
18249
18250 case cFLOWERS:
18251 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18252 10 break;
18253
18254 case cTALLGRASS:
18255 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18256 10 break;
18257
18258 case cSLASHNEXT:
18259 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18260 break;
18261
18262 case cSLASHNEXTITEM:
18263 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18264 break;
18265
18266 case cBUSHNEXT:
18267 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18268 break;
18269 }
18270 587520 }
18271 9 }
18272
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 85 times.
87 if (section_version < 16)
18273 {
18274
2/2
✓ Branch 0 taken 5548800 times.
✓ Branch 1 taken 85 times.
5548885 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18275 {
18276
2/2
✓ Branch 0 taken 5543143 times.
✓ Branch 1 taken 5657 times.
5548800 if (combobuf[tmpcounter].type == cWATER)
18277 {
18278 5657 combobuf[tmpcounter].attributes[0] = 40000L;
18279 5657 }
18280 5548800 }
18281 85 }
18282
3/4
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 1 times.
87 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18283 {
18284 1 combobuf[0].walk = 0xF0;
18285 1 combobuf[0].type = 0;
18286 1 combobuf[0].flag = 0;
18287 1 }
18288 87 }
18289
18290 //Now for the new combo alias reset
18291
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
87 if(section_version<2 && keepdata)
18292 {
18293
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18294 {
18295 73728 combo_aliases[j].width = 0;
18296 73728 combo_aliases[j].height = 0;
18297 73728 combo_aliases[j].layermask = 0;
18298
18299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18300 {
18301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].combos;
18302 73728 }
18303
18304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18305 {
18306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].csets;
18307 73728 }
18308
18309
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].combos = new word[1];
18310
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].csets = new byte[1];
18311 73728 combo_aliases[j].combos[0] = 0;
18312 73728 combo_aliases[j].csets[0] = 0;
18313 73728 }
18314 9 }
18315
18316
18317
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations();
18318
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations2();
18319 87 return 0;
18320 87 }
18321 190484 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18322 {
18323 byte combo_has_flags;
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190484 times.
190484 if(!p_getc(&combo_has_flags,f,true))
18325 return qe_invalid;
18326
18327 190484 temp_combo.clear();
18328
2/2
✓ Branch 0 taken 123933 times.
✓ Branch 1 taken 66551 times.
190484 if(combo_has_flags)
18329 {
18330
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 66548 times.
66551 if(combo_has_flags&CHAS_BASIC)
18331 {
18332
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_igetl(&temp_combo.tile,f,true))
18333 {
18334 return qe_invalid;
18335 }
18336 66548 temp_combo.o_tile = temp_combo.tile;
18337
18338
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.flip,f,true))
18339 {
18340 return qe_invalid;
18341 }
18342
18343
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.walk,f,true))
18344 {
18345 return qe_invalid;
18346 }
18347
18348
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.type,f,true))
18349 {
18350 return qe_invalid;
18351 }
18352
18353
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.flag,f,true))
18354 {
18355 return qe_invalid;
18356 }
18357
18358
1/2
✓ Branch 0 taken 66548 times.
✗ Branch 1 not taken.
66548 if(!p_getc(&temp_combo.csets,f,true))
18359 {
18360 return qe_invalid;
18361 }
18362 66548 }
18363
2/2
✓ Branch 0 taken 66528 times.
✓ Branch 1 taken 23 times.
66551 if(combo_has_flags&CHAS_SCRIPT)
18364 {
18365
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18366 {
18367 8 p_getcstr(&temp_combo.label, f, true);
18368 8 }
18369 else
18370 {
18371 char label[12];
18372 15 label[11] = '\0';
18373
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18374 {
18375
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f,true))
18376 {
18377 return qe_invalid;
18378 }
18379 165 }
18380 15 temp_combo.label = label;
18381 }
18382
18383
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18384
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18385 {
18386
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f,true))
18387 {
18388 return qe_invalid;
18389 }
18390 46 }
18391 23 }
18392
2/2
✓ Branch 0 taken 47800 times.
✓ Branch 1 taken 18751 times.
66551 if(combo_has_flags&CHAS_ANIM)
18393 {
18394
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.frames,f,true))
18395 {
18396 return qe_invalid;
18397 }
18398
18399
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.speed,f,true))
18400 {
18401 return qe_invalid;
18402 }
18403
18404
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_igetw(&temp_combo.nextcombo,f,true))
18405 {
18406 return qe_invalid;
18407 }
18408
18409
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.nextcset,f,true))
18410 {
18411 return qe_invalid;
18412 }
18413
18414
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.skipanim,f,true))
18415 {
18416 return qe_invalid;
18417 }
18418
18419
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.skipanimy,f,true))
18420 {
18421 return qe_invalid;
18422 }
18423
18424
1/2
✓ Branch 0 taken 18751 times.
✗ Branch 1 not taken.
18751 if(!p_getc(&temp_combo.animflags,f,true))
18425 {
18426 return qe_invalid;
18427 }
18428 18751 }
18429
2/2
✓ Branch 0 taken 58264 times.
✓ Branch 1 taken 8287 times.
66551 if(combo_has_flags&CHAS_ATTRIB)
18430 {
18431
2/2
✓ Branch 0 taken 33148 times.
✓ Branch 1 taken 8287 times.
41435 for ( int32_t q = 0; q < 4; q++ )
18432 {
18433
1/2
✓ Branch 0 taken 33148 times.
✗ Branch 1 not taken.
33148 if(!p_igetl(&temp_combo.attributes[q],f,true))
18434 {
18435 return qe_invalid;
18436 }
18437 33148 }
18438
2/2
✓ Branch 0 taken 66296 times.
✓ Branch 1 taken 8287 times.
74583 for ( int32_t q = 0; q < 8; q++ )
18439 {
18440
1/2
✓ Branch 0 taken 66296 times.
✗ Branch 1 not taken.
66296 if(!p_getc(&temp_combo.attribytes[q],f,true))
18441 {
18442 return qe_invalid;
18443 }
18444 66296 }
18445
2/2
✓ Branch 0 taken 66296 times.
✓ Branch 1 taken 8287 times.
74583 for ( int32_t q = 0; q < 8; q++ )
18446 {
18447
1/2
✓ Branch 0 taken 66296 times.
✗ Branch 1 not taken.
66296 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18448 {
18449 return qe_invalid;
18450 }
18451 66296 }
18452 8287 }
18453
2/2
✓ Branch 0 taken 64767 times.
✓ Branch 1 taken 1784 times.
66551 if(combo_has_flags&CHAS_FLAG)
18454 {
18455
1/2
✓ Branch 0 taken 1784 times.
✗ Branch 1 not taken.
1784 if(!p_igetl(&temp_combo.usrflags,f,true))
18456 {
18457 return qe_invalid;
18458 }
18459
1/2
✓ Branch 0 taken 1784 times.
✗ Branch 1 not taken.
1784 if(!p_igetw(&temp_combo.genflags,f,true))
18460 {
18461 return qe_invalid;
18462 }
18463 1784 }
18464
2/2
✓ Branch 0 taken 66022 times.
✓ Branch 1 taken 529 times.
66551 if(combo_has_flags&CHAS_TRIG)
18465 {
18466 529 int numtrigs = s_version < 36 ? 3 : 6;
18467
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 529 times.
3274 for ( int32_t q = 0; q < numtrigs; q++ )
18468 {
18469
1/2
✓ Branch 0 taken 2745 times.
✗ Branch 1 not taken.
2745 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18470 {
18471 return qe_invalid;
18472 }
18473 2745 }
18474
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18475 {
18476 return qe_invalid;
18477 }
18478
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triggerbtn,f,true))
18479 {
18480 return qe_invalid;
18481 }
18482
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triggeritem,f,true))
18483 {
18484 return qe_invalid;
18485 }
18486
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigtimer,f,true))
18487 {
18488 return qe_invalid;
18489 }
18490
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigsfx,f,true))
18491 {
18492 return qe_invalid;
18493 }
18494
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.trigchange,f,true))
18495 {
18496 return qe_invalid;
18497 }
18498
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.trigprox,f,true))
18499 {
18500 return qe_invalid;
18501 }
18502
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigctr,f,true))
18503 {
18504 return qe_invalid;
18505 }
18506
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18507 {
18508 return qe_invalid;
18509 }
18510
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.triglbeam,f,true))
18511 {
18512 return qe_invalid;
18513 }
18514
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcschange,f,true))
18515 {
18516 return qe_invalid;
18517 }
18518
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.spawnitem,f,true))
18519 {
18520 return qe_invalid;
18521 }
18522
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18523 {
18524 return qe_invalid;
18525 }
18526
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.exstate,f,true))
18527 {
18528 return qe_invalid;
18529 }
18530
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetl(&temp_combo.spawnip,f,true))
18531 {
18532 return qe_invalid;
18533 }
18534
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcopycat,f,true))
18535 {
18536 return qe_invalid;
18537 }
18538
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.trigcooldown,f,true))
18539 {
18540 return qe_invalid;
18541 }
18542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(s_version >= 35)
18543 {
18544
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18545 {
18546 return qe_invalid;
18547 }
18548
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_getc(&temp_combo.prompt_cs,f,true))
18549 {
18550 return qe_invalid;
18551 }
18552
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_x,f,true))
18553 {
18554 return qe_invalid;
18555 }
18556
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(!p_igetw(&temp_combo.prompt_y,f,true))
18557 {
18558 return qe_invalid;
18559 }
18560 529 }
18561
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 386 times.
529 if(s_version >= 36)
18562 {
18563
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_getc(&temp_combo.trig_lstate,f,true))
18564 {
18565 return qe_invalid;
18566 }
18567
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_getc(&temp_combo.trig_gstate,f,true))
18568 {
18569 return qe_invalid;
18570 }
18571
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18572 {
18573 return qe_invalid;
18574 }
18575 386 }
18576
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 386 times.
529 if(s_version >= 37)
18577 {
18578
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18579 {
18580 return qe_invalid;
18581 }
18582 386 }
18583
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 312 times.
529 if(s_version >= 38)
18584 {
18585
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_getc(&temp_combo.trig_group,f,true))
18586 {
18587 return qe_invalid;
18588 }
18589
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18590 {
18591 return qe_invalid;
18592 }
18593 312 }
18594 529 }
18595
2/2
✓ Branch 0 taken 66432 times.
✓ Branch 1 taken 119 times.
66551 if(combo_has_flags&CHAS_LIFT)
18596 {
18597
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftcmb,f,true))
18598 return qe_invalid;
18599
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftcs,f,true))
18600 return qe_invalid;
18601
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18602 return qe_invalid;
18603
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftundercs,f,true))
18604 return qe_invalid;
18605
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftdmg,f,true))
18606 return qe_invalid;
18607
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftlvl,f,true))
18608 return qe_invalid;
18609
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftitm,f,true))
18610 return qe_invalid;
18611
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftflags,f,true))
18612 return qe_invalid;
18613
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftgfx,f,true))
18614 return qe_invalid;
18615
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftsprite,f,true))
18616 return qe_invalid;
18617
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftsfx,f,true))
18618 return qe_invalid;
18619
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18620 return qe_invalid;
18621
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18622 return qe_invalid;
18623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(s_version >= 34)
18624 {
18625
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.lifthei,f,true))
18626 return qe_invalid;
18627
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!p_getc(&temp_combo.lifttime,f,true))
18628 return qe_invalid;
18629 119 }
18630
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 112 times.
119 if(s_version >= 39)
18631 {
18632
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&temp_combo.lift_parent_item,f,true))
18633 return qe_invalid;
18634 112 }
18635 119 }
18636
2/2
✓ Branch 0 taken 66535 times.
✓ Branch 1 taken 16 times.
66551 if(combo_has_flags&CHAS_GENERAL)
18637 {
18638
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_mult,f,true))
18639 return qe_invalid;
18640
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_div,f,true))
18641 return qe_invalid;
18642
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetzf(&temp_combo.speed_add,f,true))
18643 return qe_invalid;
18644 16 }
18645 66551 }
18646 190484 update_combo(temp_combo, s_version);
18647 190484 return 0;
18648 190484 }
18649 115 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18650 {
18651 115 word section_version=0;
18652 115 word section_cversion=0;
18653 115 word combos_used=0;
18654 int32_t dummy;
18655 byte padding;
18656 115 newcombo temp_combo;
18657
18658
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 reset_combo_animations();
18659
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 reset_combo_animations2();
18660
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 init_combo_classes();
18661
18662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true) //reset combos
18663 {
18664
2/2
✓ Branch 0 taken 7507200 times.
✓ Branch 1 taken 115 times.
7507315 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18665
1/2
✓ Branch 0 taken 7507200 times.
✗ Branch 1 not taken.
7507200 combobuf[q].clear();
18666 115 }
18667
18668
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(version > 0x192) //Version info
18669 {
18670
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&section_version,f,true))
18671 {
18672 return qe_invalid;
18673 }
18674 111 FFCore.quest_format[vCombos] = section_version;
18675
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&section_cversion,f,true))
18676 {
18677 return qe_invalid;
18678 }
18679
18680 //section size
18681
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetl(&dummy,f,true))
18682 {
18683 return qe_invalid;
18684 }
18685 111 }
18686
18687
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(section_version > 32) //Cleanup time!
18688 {
18689
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 if(!p_igetw(&combos_used,f,true))
18690 {
18691 return qe_invalid;
18692 }
18693
2/2
✓ Branch 0 taken 190484 times.
✓ Branch 1 taken 28 times.
190512 for(int32_t i=0; i<combos_used; i++)
18694 {
18695
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 auto ret = readcombo_loop(f,section_version,temp_combo);
18696
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 if(ret) return ret;
18697
2/4
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190484 times.
✗ Branch 3 not taken.
190484 if(keepdata==true && i>=start_combo)
18698
1/2
✓ Branch 0 taken 190484 times.
✗ Branch 1 not taken.
190484 combobuf[i] = temp_combo;
18699 190484 }
18700 28 }
18701 else //Call the old function for all old versions
18702 {
18703
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(ret) return ret; //error, end read
18705 }
18706
18707
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(keepdata==true)
18708 {
18709
3/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 88 times.
115 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18710 {
18711 27 combobuf[0].walk = 0xF0;
18712 27 combobuf[0].type = 0;
18713 27 combobuf[0].flag = 0;
18714 27 }
18715 115 }
18716
18717
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 setup_combo_animations();
18718
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 setup_combo_animations2();
18719 115 return 0;
18720 115 }
18721
18722 106 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18723 {
18724 //these are here to bypass compiler warnings about unused arguments
18725 106 Header=Header;
18726 106 version=version;
18727 106 build=build;
18728
18729 int32_t dummy;
18730 106 word sversion=0, c_sversion;
18731
18732 //section version info
18733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&sversion,f,true))
18734 {
18735 return qe_invalid;
18736 }
18737
18738 106 FFCore.quest_format[vComboAliases] = sversion;
18739
18740 //al_trace("Combo aliases version %d\n", sversion);
18741
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&c_sversion,f,true))
18742 {
18743 return qe_invalid;
18744 }
18745
18746 //section size
18747
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy,f,true))
18748 {
18749 return qe_invalid;
18750 }
18751
18752 106 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18753
18754
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 76 times.
106 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18755 {
18756 76 max_num_combo_aliases = MAX250COMBOALIASES;
18757 76 }
18758
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18759 {
18760 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18761 }
18762
18763
2/2
✓ Branch 0 taken 401408 times.
✓ Branch 1 taken 106 times.
401514 for(int32_t j=0; j<max_num_combo_aliases; j++)
18764 {
18765 byte width,height,mask,tempcset;
18766 int32_t count;
18767 word tempword;
18768 byte tempbyte;
18769
18770
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(!p_igetw(&tempword,f,true))
18771 {
18772 return qe_invalid;
18773 }
18774
18775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401408 times.
401408 if(keepdata)
18776 {
18777 401408 combo_aliases[j].combo = tempword;
18778 401408 }
18779
18780
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(!p_getc(&tempbyte,f,true))
18781 {
18782 return qe_invalid;
18783 }
18784
18785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401408 times.
401408 if(keepdata)
18786 {
18787 401408 combo_aliases[j].cset = tempbyte;
18788 401408 }
18789
18790
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(!p_getc(&width,f,true))
18791 {
18792 return qe_invalid;
18793 }
18794
18795
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(!p_getc(&height,f,true))
18796 {
18797 return qe_invalid;
18798 }
18799
18800
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(!p_getc(&mask,f,true))
18801 {
18802 return qe_invalid;
18803 }
18804
18805 401408 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18806
18807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401408 times.
401408 if(keepdata)
18808 {
18809
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(combo_aliases[j].combos != NULL)
18810 {
18811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401408 times.
401408 delete[] combo_aliases[j].combos;
18812 401408 }
18813
18814
1/2
✓ Branch 0 taken 401408 times.
✗ Branch 1 not taken.
401408 if(combo_aliases[j].csets != NULL)
18815 {
18816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401408 times.
401408 delete[] combo_aliases[j].csets;
18817 401408 }
18818
18819 401408 combo_aliases[j].width = width;
18820 401408 combo_aliases[j].height = height;
18821 401408 combo_aliases[j].layermask = mask;
18822 401408 combo_aliases[j].combos = new word[count];
18823 401408 combo_aliases[j].csets = new byte[count];
18824 401408 }
18825
18826
2/2
✓ Branch 0 taken 411133 times.
✓ Branch 1 taken 401408 times.
812541 for(int32_t k=0; k<count; k++)
18827 {
18828
1/2
✓ Branch 0 taken 411133 times.
✗ Branch 1 not taken.
411133 if(!p_igetw(&tempword,f,true))
18829 {
18830 return qe_invalid;
18831 }
18832
18833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411133 times.
411133 if(keepdata)
18834 {
18835 411133 combo_aliases[j].combos[k] = tempword;
18836 411133 }
18837 411133 }
18838
18839
2/2
✓ Branch 0 taken 411133 times.
✓ Branch 1 taken 401408 times.
812541 for(int32_t k=0; k<count; k++)
18840 {
18841
1/2
✓ Branch 0 taken 411133 times.
✗ Branch 1 not taken.
411133 if(!p_getc(&tempcset,f,true))
18842 {
18843 return qe_invalid;
18844 }
18845
18846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411133 times.
411133 if(keepdata)
18847 {
18848 411133 combo_aliases[j].csets[k] = tempcset;
18849 411133 }
18850 411133 }
18851 401408 }
18852
18853 106 word num_combo_pools = 0;
18854
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 28 times.
106 if(sversion >= 4)
18855 {
18856
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_igetw(&num_combo_pools,f,true))
18857 {
18858 return qe_invalid;
18859 }
18860 28 }
18861
18862
2/2
✓ Branch 0 taken 868352 times.
✓ Branch 1 taken 106 times.
868458 for(combo_pool& pool : combo_pools)
18863 {
18864 868352 pool.clear();
18865 }
18866
18867 106 combo_pool temp_cpool;
18868
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 106 times.
181 for(word cp = 0; cp < num_combo_pools; ++cp)
18869 {
18870 75 int32_t num_combos_in_pool = 0;
18871
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_igetl(&num_combos_in_pool,f,true))
18872 {
18873 return qe_invalid;
18874 }
18875
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(num_combos_in_pool < 1) continue; //nothing to read
18876
18877
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cpool.clear();
18878
18879 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18880
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 75 times.
400 for(auto q = 0; q < num_combos_in_pool; ++q)
18881 {
18882
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_igetl(&cp_cid,f,true))
18883 {
18884 return qe_invalid;
18885 }
18886
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_getc(&cp_cs,f,true))
18887 {
18888 return qe_invalid;
18889 }
18890
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 325 times.
✗ Branch 3 not taken.
325 if(!p_igetw(&cp_quant,f,true))
18891 {
18892 return qe_invalid;
18893 }
18894
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18895 325 }
18896
18897
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(keepdata)
18898 {
18899
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_pools[cp] = temp_cpool;
18900 75 }
18901 75 }
18902
18903 106 return 0;
18904 106 }
18905
18906 115 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18907 {
18908 //these are here to bypass compiler warnings about unused arguments
18909
18910 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18911 //Capitalized cause it'll save you a headache. -Deedee
18912 115 start_cset=start_cset;
18913 115 max_csets=max_csets;
18914 115 word s_version=0;
18915
18916 miscQdata temp_misc;
18917 115 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18918
18919 byte temp_colordata[48];
18920 char temp_palname[PALNAMESIZE];
18921
18922 int32_t dummy;
18923 word palcycles;
18924
18925
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(version > 0x192)
18926 {
18927 //section version info
18928
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
18929 {
18930 return qe_invalid;
18931 }
18932
18933 111 FFCore.quest_format[vCSets] = s_version;
18934
18935 //al_trace("Color data version %d\n", s_version);
18936
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy,f,true))
18937 {
18938 return qe_invalid;
18939 }
18940
18941 //section size
18942
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
18943 {
18944 return qe_invalid;
18945 }
18946 111 }
18947
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
115 if (s_version < 5)
18948 {
18949
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
85 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18950
18951 //finally... section data
18952 85 int32_t q = 0;
18953 85 int32_t p = -15;
18954
2/2
✓ Branch 0 taken 20400 times.
✓ Branch 1 taken 85 times.
20485 for(int32_t i=0; i<oldpdTOTAL; ++i)
18955 {
18956 20400 memset(temp_colordata, 0, 48);
18957
18958
1/2
✓ Branch 0 taken 20400 times.
✗ Branch 1 not taken.
20400 if(!pfread(temp_colordata,48,f,true))
18959 {
18960 return qe_invalid;
18961 }
18962
18963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20400 times.
20400 if(keepdata==true)
18964 {
18965 20400 memcpy(&colordata[q*48], temp_colordata, 48);
18966 20400 }
18967 20400 ++q;
18968
8/8
✓ Branch 0 taken 19040 times.
✓ Branch 1 taken 1360 times.
✓ Branch 2 taken 1445 times.
✓ Branch 3 taken 17595 times.
✓ Branch 4 taken 170 times.
✓ Branch 5 taken 1275 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 162 times.
20400 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18969 {
18970
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if (s_version < 5) //Bumping up the size of level palettes
18971 {
18972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1437 times.
1437 if(keepdata==true)
18973 {
18974 1437 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18975 1437 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18976 1437 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18977 1437 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18978 1437 }
18979 1437 q+=4;
18980 1437 }
18981 else
18982 {
18983 for(int m = 0; m < 4; ++m)
18984 {
18985 memset(temp_colordata, 0, 48);
18986 if(!pfread(temp_colordata,48,f,true))
18987 {
18988 return qe_invalid;
18989 }
18990 if(keepdata==true)
18991 {
18992 memcpy(&colordata[q*48], temp_colordata, 48);
18993 }
18994 ++q;
18995 }
18996 }
18997 1437 }
18998 20400 ++p;
18999 20400 }
19000
19001
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
85 if(RealOldVerion)
19002 {
19003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19004 {
19005 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19006 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19007 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19008 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19009 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19010 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19011 4 }
19012 4 }
19013 else
19014 {
19015 81 memset(temp_colordata, 0, 48);
19016
19017
2/2
✓ Branch 0 taken 253773 times.
✓ Branch 1 taken 81 times.
253854 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19018 {
19019
1/2
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
253773 if(!pfread(temp_colordata,48,f,true))
19020 {
19021 return qe_invalid;
19022 }
19023
19024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253773 times.
253773 if(keepdata==true)
19025 {
19026 253773 memcpy(&colordata[q*48], temp_colordata, 48);
19027 253773 }
19028 253773 ++q;
19029
7/8
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19521 times.
✓ Branch 3 taken 234252 times.
✓ Branch 4 taken 162 times.
✓ Branch 5 taken 19359 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 10 times.
253773 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19030 {
19031
1/2
✓ Branch 0 taken 19511 times.
✗ Branch 1 not taken.
19511 if (s_version < 5) //Bumping up the size of level palettes
19032 {
19033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19511 times.
19511 if(keepdata==true)
19034 {
19035 19511 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19036 19511 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19037 19511 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19038 19511 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19039 19511 }
19040 19511 q+=4;
19041 19511 }
19042 else
19043 {
19044 for(int m = 0; m < 4; ++m)
19045 {
19046 memset(temp_colordata, 0, 48);
19047 if(!pfread(temp_colordata,48,f,true))
19048 {
19049 return qe_invalid;
19050 }
19051 if(keepdata==true)
19052 {
19053 memcpy(&colordata[q*48], temp_colordata, 48);
19054 }
19055 ++q;
19056 }
19057 }
19058 19511 }
19059 253773 ++p;
19060 253773 }
19061
19062
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 76 times.
81 if(s_version < 4)
19063 {
19064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
19065 {
19066 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19067 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19068 5 }
19069 5 }
19070 else
19071 {
19072
2/2
✓ Branch 0 taken 252928 times.
✓ Branch 1 taken 76 times.
253004 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19073 {
19074
1/2
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
252928 if(!pfread(temp_colordata,48,f,true))
19075 {
19076 return qe_invalid;
19077 }
19078
19079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252928 times.
252928 if(keepdata==true)
19080 {
19081 252928 memcpy(&colordata[q*48], temp_colordata, 48);
19082 252928 }
19083 252928 ++q;
19084
5/6
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✓ Branch 3 taken 233472 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 19304 times.
252928 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19085 {
19086
1/2
✓ Branch 0 taken 19304 times.
✗ Branch 1 not taken.
19304 if (s_version < 5) //Bumping up the size of level palettes
19087 {
19088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19304 times.
19304 if(keepdata==true)
19089 {
19090 19304 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19091 19304 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19092 19304 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19093 19304 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19094 19304 }
19095 19304 q+=4;
19096 19304 }
19097 else
19098 {
19099 for(int m = 0; m < 4; ++m)
19100 {
19101 memset(temp_colordata, 0, 48);
19102 if(!pfread(temp_colordata,48,f,true))
19103 {
19104 return qe_invalid;
19105 }
19106 if(keepdata==true)
19107 {
19108 memcpy(&colordata[q*48], temp_colordata, 48);
19109 }
19110 ++q;
19111 }
19112 }
19113 19304 }
19114 252928 ++p;
19115 252928 }
19116
19117 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19118 }
19119 }
19120 85 }
19121 else
19122 {
19123
2/2
✓ Branch 0 taken 262470 times.
✓ Branch 1 taken 30 times.
262500 for(int32_t i=0; i<pdTOTAL255; ++i)
19124 {
19125 262470 memset(temp_colordata, 0, 48);
19126
19127
1/2
✓ Branch 0 taken 262470 times.
✗ Branch 1 not taken.
262470 if(!pfread(temp_colordata,48,f,true))
19128 {
19129 return qe_invalid;
19130 }
19131
19132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262470 times.
262470 if(keepdata==true)
19133 {
19134 262470 memcpy(&colordata[i*48], temp_colordata, 48);
19135 262470 }
19136 262470 }
19137 }
19138
19139
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((version < 0x192)||((version == 0x192)&&(build<76)))
19140 {
19141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19142 {
19143 4 init_palnames();
19144 4 }
19145 4 }
19146 else
19147 {
19148 111 int32_t palnamestoread = 0;
19149
19150
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version < 3)
19151 5 palnamestoread = OLDMAXLEVELS;
19152 else
19153 106 palnamestoread = 512;
19154
19155
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 111 times.
55663 for(int32_t i=0; i<palnamestoread; ++i)
19156 {
19157 55552 memset(temp_palname, 0, PALNAMESIZE);
19158
19159
1/2
✓ Branch 0 taken 55552 times.
✗ Branch 1 not taken.
55552 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19160 {
19161 return qe_invalid;
19162 }
19163
19164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(keepdata==true)
19165 {
19166 55552 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19167 55552 }
19168 55552 }
19169
19170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(keepdata)
19171 {
19172
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 111 times.
1391 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19173 {
19174 1280 memset(palnames[i], 0, PALNAMESIZE);
19175 1280 }
19176 111 }
19177 }
19178
19179
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(version > 0x192)
19180 {
19181
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 111 times.
28527 for(int32_t i=0; i<256; i++)
19182 {
19183
2/2
✓ Branch 0 taken 85248 times.
✓ Branch 1 taken 28416 times.
113664 for(int32_t j=0; j<3; j++)
19184 {
19185 85248 temp_misc.cycles[i][j].first=0;
19186 85248 temp_misc.cycles[i][j].count=0;
19187 85248 temp_misc.cycles[i][j].speed=0;
19188 85248 }
19189 28416 }
19190
19191
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&palcycles,f,true))
19192 {
19193 return qe_invalid;
19194 }
19195
19196
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
19197 {
19198 return qe_invalid;
19199 }
19200
19201
2/2
✓ Branch 0 taken 3448 times.
✓ Branch 1 taken 111 times.
3559 for(int32_t i=0; i<palcycles; i++)
19202 {
19203
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19204 {
19205
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19206 {
19207 return qe_invalid;
19208 }
19209 10344 }
19210
19211
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19212 {
19213
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19214 {
19215 return qe_invalid;
19216 }
19217 10344 }
19218
19219
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19220 {
19221
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19222 {
19223 return qe_invalid;
19224 }
19225 10344 }
19226 3448 }
19227
19228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(keepdata==true)
19229 {
19230 111 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19231 111 }
19232 111 }
19233
19234 115 return 0;
19235 115 }
19236
19237 115 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19238 {
19239 115 int32_t tiles_used=0;
19240 115 word section_version = 0;
19241 115 word section_cversion = 0;
19242 115 int32_t section_size= 0;
19243 115 byte *temp_tile = new byte[tilesize(tf32Bit)];
19244
19245 //Tile Expansion
19246 //if ( version >= 0x254 && build >= 41 )
19247
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
115 if (version < 0x254 && build < 41)
19248 {
19249 //al_trace("Build was < 41 when reading tiles\n");
19250 85 max_tiles = ZC250MAXTILES;
19251 85 }
19252
19253 //al_trace("Max Tiles: %d\n", max_tiles);
19254
19255
2/6
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19256 {
19257 if(keepdata==true)
19258 {
19259 if(!init_tiles(true, Header))
19260 {
19261 al_trace("Unable to initialize tiles\n");
19262 }
19263 }
19264
19265 delete[] temp_tile;
19266 temp_tile=NULL;
19267 return 0;
19268 }
19269 else
19270 {
19271
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(version > 0x192)
19272 {
19273 //section version info
19274
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&section_version,f,true))
19275 {
19276 delete[] temp_tile;
19277 return qe_invalid;
19278 }
19279
19280 111 FFCore.quest_format[vTiles] = section_version;
19281
19282
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&section_cversion,f,true))
19283 {
19284 delete[] temp_tile;
19285 return qe_invalid;
19286 }
19287
19288 //section size
19289
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&section_size,f,true))
19290 {
19291 delete[] temp_tile;
19292 return qe_invalid;
19293 }
19294 111 }
19295
19296 //if ( build < 41 )
19297 //{
19298 // tiles_used = ZC250MAXTILES;
19299 //}
19300
19301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(version < 0x174)
19302 {
19303 tiles_used=TILES_PER_PAGE*4;
19304 } //no expanded tile space
19305
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 else if(version < 0x191)
19306 {
19307 4 tiles_used=OLDMAXTILES;
19308 4 }
19309 else
19310 {
19311 //finally... section data
19312
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
111 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19313 {
19314
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!p_igetl(&tiles_used,f,true))
19315 {
19316 delete[] temp_tile;
19317 return qe_invalid;
19318 }
19319 30 }
19320 else
19321 {
19322
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetw(&tiles_used,f,true))
19323 {
19324 delete[] temp_tile;
19325 return qe_invalid;
19326 }
19327 }
19328 }
19329
19330
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 tiles_used=zc_min(tiles_used, max_tiles);
19331
19332 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19333 //if ( version < 0x254 && build < 41 )
19334
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if ( version < 0x254 || (version == 0x254 && build < 41) )
19335 //if ( build < 41 )
19336 {
19337
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19338 85 }
19339 else //2.55
19340 {
19341
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19342 }
19343
19344 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19345
19346 //al_trace("tiles_used = %d\n", tiles_used);
19347
19348
2/2
✓ Branch 0 taken 2742997 times.
✓ Branch 1 taken 115 times.
2743112 for(int32_t i=0; i<tiles_used; ++i)
19349 {
19350 2742997 byte format=tf4Bit;
19351 2742997 memset(temp_tile, 0, tilesize(tf32Bit));
19352
19353
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2570759 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2742997 if((version>0x211)||((version==0x211)&&(build>4)))
19354 {
19355
1/2
✓ Branch 0 taken 2570759 times.
✗ Branch 1 not taken.
2570759 if(!p_getc(&format,f,true))
19356 {
19357 delete[] temp_tile;
19358 return qe_invalid;
19359 }
19360 2570759 }
19361
4/4
✓ Branch 0 taken 1030994 times.
✓ Branch 1 taken 1712003 times.
✓ Branch 2 taken 508127 times.
✓ Branch 3 taken 522867 times.
2742997 if(section_version > 2 && !format)
19362 {
19363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 522867 times.
522867 if(keepdata)
19364 {
19365 522867 reset_tile(buf,start_tile+i,tf4Bit);
19366 522867 }
19367 522867 continue;
19368 }
19369
19370
1/2
✓ Branch 0 taken 2220130 times.
✗ Branch 1 not taken.
2220130 if(!pfread(temp_tile,tilesize(format),f,true))
19371 {
19372 delete[] temp_tile;
19373 return qe_invalid;
19374 }
19375
19376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2220130 times.
2220130 if(keepdata==true)
19377 {
19378 2220130 buf[start_tile+i].format=format;
19379
19380
1/2
✓ Branch 0 taken 2220130 times.
✗ Branch 1 not taken.
2220130 if(buf[start_tile+i].data)
19381 {
19382 2220130 free(buf[start_tile+i].data);
19383 2220130 buf[start_tile+i].data=NULL;
19384 2220130 }
19385
19386 2220130 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19387 2220130 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19388 2220130 }
19389 2220130 }
19390 }
19391
19392
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19393 {
19394 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19395
2/2
✓ Branch 0 taken 12663300 times.
✓ Branch 1 taken 85 times.
12663385 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19396 {
19397
19398 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19399 12663300 reset_tile(buf,q,tf4Bit);
19400
19401
19402 /*
19403
19404 byte tempbyte;
19405 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19406 {
19407 tempbyte=buf[ZC250MAXTILES-1].data[i];
19408 buf[q].data[i] = tempbyte;
19409 }
19410 //int32_t temp = tempbyte=buf[130].data[i];
19411 //buf[q].data = buf[ZC250MAXTILES-1].data;
19412 */
19413 //reset_tile(buf,q,tf4Bit);
19414 12663300 }
19415
19416 85 }
19417
19418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
19419 {
19420
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
115 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19421 {
19422
2/2
✓ Branch 0 taken 4065817 times.
✓ Branch 1 taken 85 times.
4065902 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19423 {
19424 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19425 4065817 reset_tile(buf,i,tf4Bit);
19426 4065817 }
19427 85 }
19428 else
19429 {
19430
2/2
✓ Branch 0 taken 5195386 times.
✓ Branch 1 taken 30 times.
5195416 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19431 {
19432 //al_trace("Resetting tiles for build 41+\n");
19433 5195386 reset_tile(buf,i,tf4Bit);
19434 5195386 }
19435 }
19436
19437
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19438 {
19439
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19440 {
19441 byte tempbyte;
19442 int32_t floattile=wpnsbuf[iwSwim].tile;
19443
19444 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19445 {
19446 tempbyte=buf[23].data[i];
19447 buf[23].data[i]=buf[24].data[i];
19448 buf[24].data[i]=buf[25].data[i];
19449 buf[25].data[i]=buf[26].data[i];
19450 buf[26].data[i]=tempbyte;
19451 }
19452 //swim tiles are out of order, too, but nobody cared? -Z
19453 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19454 {
19455 tempbyte=buf[floattile+11].data[i];
19456 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19457 buf[floattile+12].data[i]=tempbyte;
19458 }
19459 }
19460 4 }
19461
19462
3/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19463 {
19464
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19465 {
19466 byte tempbyte;
19467
19468
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19469 {
19470 512 tempbyte=buf[130].data[i];
19471 512 buf[130].data[i]=buf[132].data[i];
19472 512 buf[132].data[i]=tempbyte;
19473
19474 512 tempbyte=buf[131].data[i];
19475 512 buf[131].data[i]=buf[133].data[i];
19476 512 buf[133].data[i]=tempbyte;
19477 512 }
19478 4 }
19479 9 }
19480
19481 115 al_trace("Registering blank tiles\n");
19482 115 register_blank_tiles();
19483 115 }
19484
19485 //memset(temp_tile, 0, tilesize(tf32Bit));
19486
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 delete[] temp_tile;
19487 115 temp_tile=NULL;
19488 115 return 0;
19489 115 }
19490
19491 115 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19492 {
19493 115 byte *mf=midi_flags;
19494 int32_t dummy;
19495 word dummy2;
19496 // zcmidi_ temp_midi;
19497 int32_t tunes_to_read;
19498 115 int32_t tune_count=0;
19499 115 word section_version=0;
19500 115 zctune temp;
19501
19502
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version < 0x193)
19503 {
19504 // mf=Header->data_flags+ZQ_MIDIS2;
19505
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19506 {
19507 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19508 4 }
19509 else
19510 {
19511 tunes_to_read=MAXCUSTOMTUNES;
19512 }
19513 4 }
19514 else
19515 {
19516 //section version info
19517
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&section_version,f,true))
19518 {
19519 return qe_invalid;
19520 }
19521
19522 111 FFCore.quest_format[vMIDIs] = section_version;
19523
19524 //al_trace("Tunes version %d\n", section_version);
19525
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy2,f,true))
19526 {
19527 return qe_invalid;
19528 }
19529
19530 //section size
19531
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
19532 {
19533 return qe_invalid;
19534 }
19535
19536 //finally... section data
19537
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19538 {
19539 return qe_invalid;
19540 }
19541
19542 111 tunes_to_read=MAXCUSTOMTUNES;
19543 }
19544
19545
2/2
✓ Branch 0 taken 28980 times.
✓ Branch 1 taken 115 times.
29095 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19546 {
19547
2/2
✓ Branch 0 taken 27104 times.
✓ Branch 1 taken 1876 times.
28980 if(get_bit(mf, i))
19548 {
19549 1876 ++tune_count;
19550 1876 }
19551 28980 }
19552
19553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
19554 {
19555 115 reset_tunes(tunes); //reset_midis(midis);
19556 115 }
19557
19558
2/2
✓ Branch 0 taken 28100 times.
✓ Branch 1 taken 115 times.
28215 for(int32_t i=0; i<tunes_to_read; i++)
19559 {
19560 28100 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19561
19562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28100 times.
28100 if(keepdata==true)
19563 {
19564 28100 tunes[i].reset(); // reset_midi(midis+i);
19565 28100 }
19566
19567
2/2
✓ Branch 0 taken 26224 times.
✓ Branch 1 taken 1876 times.
28100 if(get_bit(mf,i))
19568 {
19569
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1579 times.
1876 if(section_version < 4)
19570 {
19571
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19572 {
19573 return qe_invalid;
19574 }
19575 297 }
19576 else
19577 {
19578
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19579 {
19580 return qe_invalid;
19581 }
19582 }
19583
19584
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!p_igetl(&temp.start,f,true))
19585 {
19586 return qe_invalid;
19587 }
19588
19589
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!p_igetl(&temp.loop_start,f,true))
19590 {
19591 return qe_invalid;
19592 }
19593
19594
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!p_igetl(&temp.loop_end,f,true))
19595 {
19596 return qe_invalid;
19597 }
19598
19599
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!p_igetw(&temp.loop,f,true))
19600 {
19601 return qe_invalid;
19602 }
19603
19604
1/2
✓ Branch 0 taken 1876 times.
✗ Branch 1 not taken.
1876 if(!p_igetw(&temp.volume,f,true))
19605 {
19606 return qe_invalid;
19607 }
19608
19609
2/2
✓ Branch 0 taken 1798 times.
✓ Branch 1 taken 78 times.
1876 if(Header->zelda_version < 0x193)
19610 {
19611
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19612 {
19613 return qe_invalid;
19614 }
19615 78 }
19616
19617
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1579 times.
1876 if(section_version >= 3)
19618 {
19619
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19620 {
19621 return qe_invalid;
19622 }
19623 1579 }
19624
19625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1876 times.
1876 if(keepdata==true)
19626 {
19627 1876 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19628 1876 }
19629
19630
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1579 times.
1876 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19631 {
19632 // old format - a midi is a midi
19633
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19634 {
19635 return qe_invalid;
19636 }
19637
19638 //yes you can do this. Isn't the ? operator awesome? :)
19639
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19640 297 }
19641 else
19642 {
19643 // 'midi' could be midi or nes, gb, ... music
19644
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1579 times.
✗ Branch 3 not taken.
1579 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19645 {
19646 return qe_invalid;
19647 }
19648
19649
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19650
19651
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 switch(temp.format)
19652 {
19653 case MFORMAT_MIDI:
19654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 if((ptr->data=read_midi(f, true))==NULL)
19655 {
19656 return qe_invalid;
19657 }
19658
19659 1579 break;
19660
19661 default:
19662 return qe_invalid;
19663 break;
19664 }
19665 }
19666 1876 }
19667 28100 }
19668
19669 115 return 0;
19670 115 }
19671
19672 115 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19673 {
19674 int32_t dummy;
19675 ZCHEATS tempzcheats;
19676 115 char temp_use_cheats=1;
19677 115 memset(&tempzcheats, 0, sizeof(tempzcheats));
19678 115 word s_version = 0;
19679
19680
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
115 if(Header->zelda_version > 0x192)
19681 {
19682 //section version info
19683
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&s_version,f,true))
19684 {
19685 return qe_invalid;
19686 }
19687
19688 111 FFCore.quest_format[vCheats] = s_version;
19689 //al_trace("Cheats version %d\n", dummy);
19690
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetw(&dummy,f,true))
19691 {
19692 return qe_invalid;
19693 }
19694
19695 //section size
19696
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&dummy,f,true))
19697 {
19698 return qe_invalid;
19699 }
19700
19701 //finally... section data
19702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&temp_use_cheats,f,true))
19703 {
19704 return qe_invalid;
19705 }
19706 111 }
19707
19708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(Header->data_flags[ZQ_CHEATS2])
19709 {
19710
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&tempzcheats.flags,f,true))
19711 {
19712 return qe_invalid;
19713 }
19714
19715
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19716 {
19717 return qe_invalid;
19718 }
19719 115 }
19720
19721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(keepdata==true)
19722 {
19723 115 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19724 115 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19725 115 }
19726
19727 115 return 0;
19728 115 }
19729
19730 277 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19731 {
19732 int32_t dummy;
19733 277 word s_version=0, s_cversion=0;
19734 byte padding;
19735 word tempw;
19736
19737 277 zinitdata temp_zinit;
19738
19739 // Legacy item properties (now integrated into itemdata)
19740 byte sword_hearts[4];
19741 byte beam_hearts[4];
19742 277 byte beam_percent=0;
19743 word beam_power[4];
19744 277 byte hookshot_length=99;
19745 277 byte hookshot_links=100;
19746 277 byte longshot_length=99;
19747 277 byte longshot_links=100;
19748 277 byte moving_fairy_hearts=3;
19749 277 byte moving_fairy_heart_percent=0;
19750 277 byte stationary_fairy_hearts=3;
19751 277 byte stationary_fairy_heart_percent=0;
19752 277 byte moving_fairy_magic=0;
19753 277 byte moving_fairy_magic_percent=0;
19754 277 byte stationary_fairy_magic=0;
19755 277 byte stationary_fairy_magic_percent=0;
19756 277 byte blue_potion_hearts=100;
19757 277 byte blue_potion_heart_percent=1;
19758 277 byte red_potion_hearts=100;
19759 277 byte red_potion_heart_percent=1;
19760 277 byte blue_potion_magic=100;
19761 277 byte blue_potion_magic_percent=1;
19762 277 byte red_potion_magic=100;
19763 277 byte red_potion_magic_percent=1;
19764
19765
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 162 times.
277 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19766
19767
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(Header->zelda_version > 0x192)
19768 {
19769 //section version info
19770
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&s_version,f,true))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 111 FFCore.quest_format[vInitData] = s_version;
19776
19777 //al_trace("Init data version %d\n", s_version);
19778
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&s_cversion,f,true))
19779 {
19780 return qe_invalid;
19781 }
19782
19783 //section size
19784
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetl(&dummy,f,true))
19785 {
19786 return qe_invalid;
19787 }
19788 111 }
19789
19790 /* HIGHLY UNORTHODOX UPDATING THING, by L
19791 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19792 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19793 * changing from 13 to 14.
19794 */
19795
3/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 9 times.
115 if(keepdata && s_version < 14)
19796 9 fixpolsvoice=true;
19797
19798 /* End highly unorthodox updating thing */
19799
19800
5/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 32 times.
115 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19801 32 temp_zinit.jump_hero_layer_threshold=0;
19802
19803
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
115 if(s_version >= 10)
19804 {
19805 char temp;
19806
19807 //new-style items
19808
2/2
✓ Branch 0 taken 27136 times.
✓ Branch 1 taken 106 times.
27242 for(int32_t j=0; j<256; j++)
19809 {
19810
2/4
✓ Branch 0 taken 27136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27136 times.
27136 if(!p_getc(&temp,f,true))
19811 return qe_invalid;
19812
19813 27136 temp_zinit.items[j] = (temp != 0);
19814 27136 }
19815 106 }
19816
19817
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 51 times.
115 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19818 {
19819 char temp;
19820
19821 //finally... section data
19822
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 51 times.
162 if((Header->zelda_version > 0x192)||
19823 //new only
19824 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19825 {
19826 //OLD-style items... sigh
19827
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version < 10)
19828 {
19829
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19830 {
19831 return qe_invalid;
19832 }
19833
19834 5 temp_zinit.items[iRaft]=(temp != 0);
19835
19836
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19837 {
19838 return qe_invalid;
19839 }
19840
19841 5 temp_zinit.items[iLadder]=(temp != 0);
19842
19843
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19844 {
19845 return qe_invalid;
19846 }
19847
19848 5 temp_zinit.items[iBook]=(temp != 0);
19849
19850
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19851 {
19852 return qe_invalid;
19853 }
19854
19855 5 temp_zinit.items[iMKey]=(temp!=0);
19856
19857
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19858 {
19859 return qe_invalid;
19860 }
19861
19862 5 temp_zinit.items[iFlippers]=(temp != 0);
19863
19864
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19865 {
19866 return qe_invalid;
19867 }
19868
19869 5 temp_zinit.items[iBoots]=(temp!=0);
19870 5 }
19871 111 }
19872
19873
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 157 times.
162 if(s_version < 10)
19874 {
19875 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19876
19877
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19878 {
19879 return qe_invalid;
19880 }
19881
19882
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19883 {
19884 return qe_invalid;
19885 }
19886
19887
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19888 {
19889 return qe_invalid;
19890 }
19891
19892
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19893 {
19894 return qe_invalid;
19895 }
19896
19897
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19898 {
19899 return qe_invalid;
19900 }
19901
19902
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19903 {
19904 return qe_invalid;
19905 }
19906
19907
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19908 {
19909 return qe_invalid;
19910 }
19911
19912 //old only
19913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19914 {
19915 tempring=(tempring)?(1<<(tempring-1)):0;
19916 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19917 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19918 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19919 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19920 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19921 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19922 }
19923
19924 //rings start at level 2... wtf
19925 //account for this -DD
19926 5 tempring <<= 1;
19927
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19928
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19929
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19930
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19931 //bracelet ALSO starts at level 2 :-( -DD
19932 5 tempbracelet<<=1;
19933
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19934
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19935
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19936
19937 //new only
19938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19939 {
19940 for(int32_t q=0; q<32; q++)
19941 {
19942 if(!p_getc(&padding,f,true))
19943 {
19944 return qe_invalid;
19945 }
19946 }
19947 }
19948
19949 char tempcandle, tempboomerang, temparrow, tempwhistle;
19950
19951
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19952 {
19953 return qe_invalid;
19954 }
19955
19956
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19957 {
19958 return qe_invalid;
19959 }
19960
19961
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19962 {
19963 return qe_invalid;
19964 }
19965
19966
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19967 {
19968 return qe_invalid;
19969 }
19970
19971
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19972
19973
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19974 {
19975 return qe_invalid;
19976 }
19977
19978 //old only
19979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19980 {
19981 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19982 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19983 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19984 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19985 }
19986
19987
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19988
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19989
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19990
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19991 //What about the potion...?
19992
19993 5 }
19994
19995
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 81 times.
162 if(s_version < 29)
19996 {
19997 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19998 //to jab out my eye...
19999
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20000 return qe_invalid;
20001 81 temp_zinit.bombs = padding;
20002
20003
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20004 return qe_invalid;
20005 81 temp_zinit.super_bombs = padding;
20006 81 }
20007
20008 //Back to more OLD item code
20009
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
162 if(s_version < 10)
20010 {
20011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
20012 //new only
20013 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20014 {
20015
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20016 {
20017 return qe_invalid;
20018 }
20019
20020
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20021
20022
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20023 {
20024 return qe_invalid;
20025 }
20026
20027
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20028
20029
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20030 {
20031 return qe_invalid;
20032 }
20033
20034
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20035
20036
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20037 {
20038 return qe_invalid;
20039 }
20040
20041
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20042
20043
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20044 {
20045 return qe_invalid;
20046 }
20047
20048
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20049
20050
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20051 {
20052 return qe_invalid;
20053 }
20054
20055
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20056
20057
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20058 {
20059 return qe_invalid;
20060 }
20061
20062
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20063
20064
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20065 {
20066 return qe_invalid;
20067 }
20068
20069
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20070
20071
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20072 {
20073 return qe_invalid;
20074 }
20075
20076
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20077
20078
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
20079 {
20080 return qe_invalid;
20081 }
20082
20083
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
20084 {
20085 for(int32_t q=0; q<32; q++)
20086 {
20087 if(!p_getc(&padding,f,true))
20088 {
20089 return qe_invalid;
20090 }
20091 }
20092 }
20093 5 }
20094 5 }
20095
20096 //old only
20097
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
20098 {
20099 byte equipment, items; //bit flags
20100
20101 if(!p_getc(&equipment,f,true))
20102 {
20103 return qe_invalid;
20104 }
20105
20106 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
20107 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
20108 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
20109 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
20110 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
20111 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
20112
20113
20114 if(!p_getc(&items,f,true))
20115 {
20116 return qe_invalid;
20117 }
20118
20119 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
20120 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
20121 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
20122 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
20123 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
20124 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
20125 }
20126
20127 if(!p_getc(&temp_zinit.hc,f,true))
20128 {
20129 return qe_invalid;
20130 }
20131
20132
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version < 14)
20133 {
20134 byte temphp;
20135
20136
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20137 {
20138 return qe_invalid;
20139 }
20140
20141 5 temp_zinit.start_heart=temphp;
20142
20143
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20144 {
20145 return qe_invalid;
20146 }
20147
20148 5 temp_zinit.cont_heart=temphp;
20149 5 }
20150 else
20151 {
20152
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.start_heart,f,true))
20153 {
20154 return qe_invalid;
20155 }
20156
20157
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20158 {
20159 return qe_invalid;
20160 }
20161 }
20162
20163
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.hcp,f,true))
20164 {
20165 return qe_invalid;
20166 }
20167
20168
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version >= 14)
20169 {
20170
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174
20175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version<16) // July 2007
20176 {
20177 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20178 temp_zinit.hcp_per_hc = 0xFF;
20179
20180 //Dispose of legacy rule
20181 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20182 }
20183 106 }
20184
20185
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if(s_version < 29)
20186 {
20187
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20188 return qe_invalid;
20189 81 temp_zinit.max_bombs = padding;
20190 81 }
20191
20192
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.keys,f,true))
20193 {
20194 return qe_invalid;
20195 }
20196
20197
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_igetw(&temp_zinit.rupies,f,true))
20198 {
20199 return qe_invalid;
20200 }
20201
20202
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.triforce,f,true))
20203 {
20204 return qe_invalid;
20205 }
20206
20207
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20208 {
20209
2/2
✓ Branch 0 taken 6784 times.
✓ Branch 1 taken 106 times.
6890 for(int32_t i=0; i<64; i++)
20210 {
20211
2/4
✓ Branch 0 taken 6784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6784 times.
6784 if(!p_getc(&temp_zinit.map[i],f,true))
20212 {
20213 return qe_invalid;
20214 }
20215 6784 }
20216
20217
2/2
✓ Branch 0 taken 6784 times.
✓ Branch 1 taken 106 times.
6890 for(int32_t i=0; i<64; i++)
20218 {
20219
2/4
✓ Branch 0 taken 6784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6784 times.
6784 if(!p_getc(&temp_zinit.compass[i],f,true))
20220 {
20221 return qe_invalid;
20222 }
20223 6784 }
20224 106 }
20225 else
20226 {
20227
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20228 {
20229
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20230 {
20231 return qe_invalid;
20232 }
20233 160 }
20234
20235
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20236 {
20237
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20238 {
20239 return qe_invalid;
20240 }
20241 160 }
20242 }
20243
20244
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if((Header->zelda_version > 0x192)||
20245 //new only
20246 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20247 {
20248
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20249 {
20250
2/2
✓ Branch 0 taken 6784 times.
✓ Branch 1 taken 106 times.
6890 for(int32_t i=0; i<64; i++)
20251 {
20252
2/4
✓ Branch 0 taken 6784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6784 times.
6784 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20253 {
20254 return qe_invalid;
20255 }
20256 6784 }
20257 106 }
20258 else
20259 {
20260
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20261 {
20262
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20263 {
20264 return qe_invalid;
20265 }
20266 160 }
20267 }
20268 111 }
20269
20270
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 1776 times.
1887 for(int32_t i=0; i<16; i++)
20271 {
20272
2/4
✓ Branch 0 taken 1776 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1776 times.
1776 if(!p_getc(&temp_zinit.misc[i],f,true))
20273 {
20274 return qe_invalid;
20275 }
20276 1776 }
20277
20278
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
131 if(s_version < 15) for(int32_t i=0; i<4; i++)
20279 {
20280
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20281 {
20282 return qe_invalid;
20283 }
20284 25 }
20285
20286
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.last_map,f,true))
20287 {
20288 return qe_invalid;
20289 }
20290
20291
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.last_screen,f,true))
20292 {
20293 return qe_invalid;
20294 }
20295
20296
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version < 14)
20297 {
20298 byte tempmp;
20299
20300
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20301 {
20302 return qe_invalid;
20303 }
20304
20305 5 temp_zinit.max_magic=tempmp;
20306
20307
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20308 {
20309 return qe_invalid;
20310 }
20311
20312 5 temp_zinit.magic=tempmp;
20313 5 }
20314 else
20315 {
20316
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.max_magic,f,true))
20317 {
20318 return qe_invalid;
20319 }
20320
20321
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.magic,f,true))
20322 {
20323 return qe_invalid;
20324 }
20325 }
20326
20327
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version < 15)
20328 {
20329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20330 {
20331 5 temp_zinit.max_magic*=32;
20332 5 temp_zinit.magic*=32;
20333 5 }
20334
20335
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20336 {
20337
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20338 {
20339 return qe_invalid;
20340 }
20341 20 }
20342
20343
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20344 {
20345 return qe_invalid;
20346 }
20347 5 }
20348 else
20349 {
20350
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20351 {
20352 return qe_invalid;
20353 }
20354 }
20355
20356
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version < 15)
20357 {
20358 byte tempbp;
20359
20360
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20361 {
20362
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20363 {
20364 return qe_invalid;
20365 }
20366
20367 20 beam_power[i]=tempbp;
20368 20 }
20369
20370
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20371 {
20372 return qe_invalid;
20373 }
20374
20375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20376 {
20377 if(!p_getc(&hookshot_length,f,true))
20378 {
20379 return qe_invalid;
20380 }
20381
20382 if(!p_getc(&longshot_links,f,true))
20383 {
20384 return qe_invalid;
20385 }
20386
20387 if(!p_getc(&longshot_length,f,true))
20388 {
20389 return qe_invalid;
20390 }
20391 }
20392 5 }
20393
20394
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20395 {
20396 return qe_invalid;
20397 }
20398
20399
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20400 {
20401 return qe_invalid;
20402 }
20403
20404
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.subscreen,f,true))
20405 {
20406 return qe_invalid;
20407 }
20408
20409 //old only
20410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if((Header->zelda_version == 0x192)&&(Header->build<174))
20411 {
20412 for(int32_t i=0; i<32; i++)
20413 {
20414 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20415 {
20416 return qe_invalid;
20417 }
20418 }
20419 }
20420
20421
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20422 {
20423
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version <= 10)
20424 {
20425 byte tempbyte;
20426
20427
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20428 {
20429 return qe_invalid;
20430 }
20431
20432 5 temp_zinit.start_dmap = (word)tempbyte;
20433 5 }
20434 else
20435 {
20436
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20437 {
20438 return qe_invalid;
20439 }
20440 }
20441
20442
2/4
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20443 {
20444 return qe_invalid;
20445 }
20446 111 }
20447
20448
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 30 times.
111 if(s_version>1 && s_version < 29)
20449 {
20450
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20451 return qe_invalid;
20452 76 temp_zinit.arrows = padding;
20453
20454
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20455 return qe_invalid;
20456 76 temp_zinit.max_arrows = padding;
20457 76 }
20458
20459
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 106 times.
111 if(s_version>2)
20460 {
20461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(s_version <= 10)
20462 {
20463 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20464 {
20465 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20466 {
20467 return qe_invalid;
20468 }
20469 }
20470 }
20471 else
20472 {
20473
2/2
✓ Branch 0 taken 54272 times.
✓ Branch 1 taken 106 times.
54378 for(int32_t i=0; i<MAXLEVELS; i++)
20474 {
20475
2/4
✓ Branch 0 taken 54272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54272 times.
✗ Branch 3 not taken.
54272 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20476 {
20477 return qe_invalid;
20478 }
20479 54272 }
20480 }
20481 106 }
20482
20483
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>3)
20484 {
20485
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20486 {
20487 return qe_invalid;
20488 }
20489
20490
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20491 {
20492 return qe_invalid;
20493 }
20494
20495
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20496 {
20497 return qe_invalid;
20498 }
20499
20500
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20501 {
20502 return qe_invalid;
20503 }
20504
20505
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20506 {
20507 return qe_invalid;
20508 }
20509
20510
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20511 {
20512 return qe_invalid;
20513 }
20514
20515
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20516 {
20517 return qe_invalid;
20518 }
20519
20520
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20521 {
20522 return qe_invalid;
20523 }
20524
20525
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20526
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20527 106 }
20528
20529
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
111 if(s_version>4 && s_version<15)
20530 {
20531 if(!p_getc(&moving_fairy_hearts,f,true))
20532 {
20533 return qe_invalid;
20534 }
20535
20536 if(!p_getc(&moving_fairy_heart_percent,f,true))
20537 {
20538 return qe_invalid;
20539 }
20540 }
20541
20542
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
111 if(s_version>5 && s_version < 10)
20543 {
20544 if(!p_getc(&temp,f,true))
20545 {
20546 return qe_invalid;
20547 }
20548
20549 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20550 }
20551
20552
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
111 if(s_version>6 && s_version<15)
20553 {
20554 if(!p_getc(&stationary_fairy_hearts,f,true))
20555 {
20556 return qe_invalid;
20557 }
20558
20559 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20560 {
20561 return qe_invalid;
20562 }
20563
20564 if(!p_getc(&moving_fairy_magic,f,true))
20565 {
20566 return qe_invalid;
20567 }
20568
20569 if(!p_getc(&moving_fairy_magic_percent,f,true))
20570 {
20571 return qe_invalid;
20572 }
20573
20574 if(!p_getc(&stationary_fairy_magic,f,true))
20575 {
20576 return qe_invalid;
20577 }
20578
20579 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20580 {
20581 return qe_invalid;
20582 }
20583
20584 if(!p_getc(&blue_potion_hearts,f,true))
20585 {
20586 return qe_invalid;
20587 }
20588
20589 if(!p_getc(&blue_potion_heart_percent,f,true))
20590 {
20591 return qe_invalid;
20592 }
20593
20594 if(!p_getc(&red_potion_hearts,f,true))
20595 {
20596 return qe_invalid;
20597 }
20598
20599 if(!p_getc(&red_potion_heart_percent,f,true))
20600 {
20601 return qe_invalid;
20602 }
20603
20604 if(!p_getc(&blue_potion_magic,f,true))
20605 {
20606 return qe_invalid;
20607 }
20608
20609 if(!p_getc(&blue_potion_magic_percent,f,true))
20610 {
20611 return qe_invalid;
20612 }
20613
20614 if(!p_getc(&red_potion_magic,f,true))
20615 {
20616 return qe_invalid;
20617 }
20618
20619 if(!p_getc(&red_potion_magic_percent,f,true))
20620 {
20621 return qe_invalid;
20622 }
20623 }
20624
20625
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>6)
20626 {
20627
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20628 {
20629 return qe_invalid;
20630 }
20631 106 }
20632
20633
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>7)
20634 {
20635
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20636 {
20637 return qe_invalid;
20638 }
20639 106 }
20640
20641
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>8)
20642 {
20643
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20644 {
20645 return qe_invalid;
20646 }
20647
20648
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.max_keys,f,true))
20649 {
20650 return qe_invalid;
20651 }
20652 106 }
20653
20654
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>16)
20655 {
20656
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.gravity,f,true))
20657 {
20658 return qe_invalid;
20659 }
20660
20661
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_igetw(&temp_zinit.terminalv,f,true))
20662 {
20663 return qe_invalid;
20664 }
20665
20666
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.msg_speed,f,true))
20667 {
20668 return qe_invalid;
20669 }
20670
20671
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.transition_type,f,true))
20672 {
20673 return qe_invalid;
20674 }
20675
20676
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20677 {
20678 return qe_invalid;
20679 }
20680 106 }
20681
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if (replay_version_check(0, 13))
20682 5 temp_zinit.msg_speed = 0;
20683
20684
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(s_version>17)
20685 {
20686
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20687 {
20688 return qe_invalid;
20689 }
20690 106 }
20691
20692 //expaned init data for larger values in 2.55
20693
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20694 {
20695
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.bombs,f,true))
20696 {
20697 return qe_invalid;
20698 }
20699
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20700 {
20701 return qe_invalid;
20702 }
20703
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20704 {
20705 return qe_invalid;
20706 }
20707
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20708 {
20709 return qe_invalid;
20710 }
20711
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.arrows,f,true))
20712 {
20713 return qe_invalid;
20714 }
20715
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20716 {
20717 return qe_invalid;
20718 }
20719
20720 30 }
20721
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if ( s_version >= 20 )
20722 {
20723
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroStep,f,true))
20724 {
20725 return qe_invalid;
20726 }
20727 30 }
20728 else
20729 {
20730 81 temp_zinit.heroStep = 150; //1.5 pixels per frame
20731 }
20732
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 81 times.
111 if ( s_version >= 21 )
20733 {
20734
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20735 {
20736 return qe_invalid;
20737 }
20738 30 }
20739 else
20740 {
20741 81 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20742 }
20743 //old only
20744
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if((Header->zelda_version == 0x192)&&(Header->build<174))
20745 {
20746 byte items2;
20747
20748 if(!p_getc(&items2,f,true))
20749 {
20750 return qe_invalid;
20751 }
20752
20753 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20754 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20755 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20756 }
20757
20758
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(Header->zelda_version < 0x193)
20759 {
20760 for(int32_t q=0; q<96; q++)
20761 {
20762 if(!p_getc(&padding,f,true))
20763 {
20764 return qe_invalid;
20765 }
20766 }
20767
20768 //new only
20769 if((Header->zelda_version == 0x192)&&(Header->build>173))
20770 {
20771 if(!p_getc(&padding,f,true))
20772 {
20773 return qe_invalid;
20774 }
20775
20776 if(!p_getc(&padding,f,true))
20777 {
20778 return qe_invalid;
20779 }
20780 }
20781 }
20782 111 }
20783
20784
3/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20785 {
20786 //temp_zinit.shield=i_smallshield;
20787
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 51 times.
60 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20788
20789
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20790 9 temp_zinit.items[sshieldid] = true;
20791 9 }
20792
20793
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20794 {
20795 4 temp_zinit.hc=3;
20796 4 temp_zinit.start_heart=3;
20797 4 temp_zinit.cont_heart=3;
20798 4 temp_zinit.max_bombs=8;
20799 4 }
20800
20801
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20802 {
20803 4 sword_hearts[0]=0;
20804 4 sword_hearts[1]=5;
20805 4 sword_hearts[2]=12;
20806 4 sword_hearts[3]=21;
20807 4 }
20808
20809
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20810 {
20811 4 temp_zinit.last_map=0;
20812 4 temp_zinit.last_screen=0;
20813 4 }
20814
20815
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20816 {
20817 4 temp_zinit.max_magic=0;
20818 4 temp_zinit.magic=0;
20819
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20820 4 }
20821
20822
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20823 {
20824
20825
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20826 {
20827 16 beam_hearts[x]=100;
20828 16 }
20829
20830
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20831 {
20832
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20833
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20834 16 }
20835
20836
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20837 {
20838
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20839 16 }
20840
20841
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20842 4 hookshot_links=100;
20843 4 temp_zinit.msg_more_x=224;
20844 4 temp_zinit.msg_more_y=64;
20845 4 }
20846
20847 // Okay, let's put these legacy values into itemsbuf.
20848
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(s_version < 15)
20849
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20850 {
20851
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20852 {
20853 case iFairyStill:
20854 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20855 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20856 9 itemsbuf[i].misc3 = 0;
20857 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20858 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20859 9 break;
20860
20861 case iFairyMoving:
20862 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20863 9 itemsbuf[i].misc2 = moving_fairy_magic;
20864 9 itemsbuf[i].misc3 = 50;
20865 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20866 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20867 9 break;
20868
20869 case iRPotion:
20870 9 itemsbuf[i].misc1 = red_potion_hearts;
20871 9 itemsbuf[i].misc2 = red_potion_magic;
20872 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20873 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20874 9 break;
20875
20876 case iBPotion:
20877 9 itemsbuf[i].misc1 = blue_potion_hearts;
20878 9 itemsbuf[i].misc2 = blue_potion_magic;
20879 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20880 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20881 9 break;
20882
20883 case iSword:
20884 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20885 9 itemsbuf[i].misc1 = beam_hearts[0];
20886 9 itemsbuf[i].misc2 = beam_power[0];
20887 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20888
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20889 9 break;
20890
20891 case iWSword:
20892 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20893 9 itemsbuf[i].misc1 = beam_hearts[1];
20894 9 itemsbuf[i].misc2 = beam_power[1];
20895
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20896 9 break;
20897
20898 case iMSword:
20899 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20900 9 itemsbuf[i].misc1 = beam_hearts[2];
20901 9 itemsbuf[i].misc2 = beam_power[2];
20902
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20903 9 break;
20904
20905 case iXSword:
20906 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20907 9 itemsbuf[i].misc1 = beam_hearts[3];
20908 9 itemsbuf[i].misc2 = beam_power[3];
20909
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20910 9 break;
20911
20912 case iHookshot:
20913 9 itemsbuf[i].misc1 = hookshot_length;
20914 9 itemsbuf[i].misc2 = hookshot_links;
20915 9 break;
20916
20917 case iLongshot:
20918 9 itemsbuf[i].misc1 = longshot_length;
20919 9 itemsbuf[i].misc2 = longshot_links;
20920 9 break;
20921 }
20922 2313 }
20923
20924
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20925 {
20926 //was new subscreen rule
20927
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20928
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20929 4 }
20930
20931
3/4
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20932 {
20933 4 temp_zinit.start_dmap=0;
20934 4 }
20935
20936
3/6
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20937 {
20938
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20939 4 }
20940
20941
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
115 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20942 {
20943 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20944 temp_zinit.max_rupees=999;
20945 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20946 }
20947
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20948 {
20949 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20950 temp_zinit.max_bombs = 8;
20951 }
20952 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20953 //time to ensure that we port all new values properly:
20954
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 9 times.
115 if(Header->zelda_version < 0x250)
20955 {
20956
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20957 9 }
20958
20959
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 21)
20960 {
20961
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20962 {
20963 return qe_invalid;
20964 }
20965
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20966 {
20967 return qe_invalid;
20968 }
20969
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20970 {
20971 return qe_invalid;
20972 }
20973
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20974 {
20975 return qe_invalid;
20976 }
20977 30 }
20978 else
20979 {
20980 85 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20981 85 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20982 85 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20983 85 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20984 }
20985
20986
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 22)
20987 {
20988
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 30 times.
780 for(int32_t q = 0; q < 25; ++q)
20989 {
20990
2/4
✓ Branch 0 taken 750 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
750 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20991 {
20992 return qe_invalid;
20993 }
20994 750 }
20995
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 30 times.
780 for(int32_t q = 0; q < 25; ++q)
20996 {
20997
2/4
✓ Branch 0 taken 750 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 750 times.
750 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20998 {
20999 return qe_invalid;
21000 }
21001 750 }
21002 30 }
21003 else
21004 {
21005
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 85 times.
2210 for(int32_t q = 0; q < 25; ++q)
21006 {
21007 2125 temp_zinit.scrcnt[q] = 0;
21008 2125 temp_zinit.scrmaxcnt[q] = 0;
21009 2125 }
21010 }
21011
21012
21013
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 23)
21014 {
21015
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_type,f,true))
21016 {
21017 return qe_invalid;
21018 }
21019
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_arg,f,true))
21020 {
21021 return qe_invalid;
21022 }
21023
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.dither_percent,f,true))
21024 {
21025 return qe_invalid;
21026 }
21027
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.def_lightrad,f,true))
21028 {
21029 return qe_invalid;
21030 }
21031
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.transdark_percent,f,true))
21032 {
21033 return qe_invalid;
21034 }
21035 30 }
21036 else
21037 {
21038 85 temp_zinit.dither_type = 0;
21039 85 temp_zinit.dither_arg = 0;
21040 85 temp_zinit.dither_percent = 20;
21041 85 temp_zinit.def_lightrad = 24;
21042 85 temp_zinit.transdark_percent = 0;
21043 }
21044
21045
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 24)
21046 {
21047
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.darkcol,f,true))
21048 {
21049 return qe_invalid;
21050 }
21051 30 }
21052 else
21053 {
21054 85 temp_zinit.darkcol = BLACK;
21055 }
21056
21057
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 25)
21058 {
21059
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.gravity2,f,true))
21060 {
21061 return qe_invalid;
21062 }
21063
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.swimgravity,f,true))
21064 {
21065 return qe_invalid;
21066 }
21067 30 }
21068 else
21069 {
21070 85 temp_zinit.gravity2 = temp_zinit.gravity*100;
21071 85 temp_zinit.swimgravity = 5;
21072 }
21073
21074
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 26)
21075 {
21076
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
21077 {
21078 return qe_invalid;
21079 }
21080
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
21081 {
21082 return qe_invalid;
21083 }
21084
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
21085 {
21086 return qe_invalid;
21087 }
21088 30 }
21089 else
21090 {
21091 85 temp_zinit.heroSideswimUpStep = 150;
21092 85 temp_zinit.heroSideswimSideStep = 100;
21093 85 temp_zinit.heroSideswimDownStep = 75;
21094 }
21095
21096
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 27)
21097 {
21098
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
21099 {
21100 return qe_invalid;
21101 }
21102 30 }
21103 else
21104 {
21105 85 temp_zinit.exitWaterJump = 0;
21106 }
21107
21108
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 29)
21109 {
21110
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
21111 {
21112 return qe_invalid;
21113 }
21114 30 }
21115 else
21116 {
21117 85 temp_zinit.bunny_ltm = 0;
21118 }
21119
21120
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 30)
21121 {
21122
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
21123 {
21124 return qe_invalid;
21125 }
21126 30 }
21127 else
21128 {
21129 85 temp_zinit.switchhookstyle = 1;
21130 }
21131
21132
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 85 times.
115 if(s_version > 31)
21133 {
21134
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21135 {
21136 return qe_invalid;
21137 }
21138 30 }
21139 else
21140 {
21141
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21142
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21143 }
21144
21145
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 temp_zinit.clear_genscript();
21146
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 87 times.
115 if(s_version > 32)
21147 {
21148 28 word numgenscript = 0;
21149
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 if(!p_igetw(&numgenscript,f,true))
21150 return qe_invalid;
21151
2/4
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
28 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
21152 return qe_invalid;
21153
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 for(auto q = 1; q < numgenscript; ++q)
21154 {
21155 if(!p_getc(&padding,f,true))
21156 return qe_invalid;
21157 if(!(padding&2))
21158 continue;
21159 temp_zinit.gen_doscript[q] = padding&1;
21160 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21161 return qe_invalid;
21162 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21163 return qe_invalid;
21164 for(auto p = 0; p < 8; ++p)
21165 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21166 return qe_invalid;
21167 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21168 return qe_invalid;
21169 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21170 return qe_invalid;
21171 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21172 return qe_invalid;
21173 }
21174 28 }
21175
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 90 times.
115 if(s_version > 33)
21176 {
21177
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21178 return qe_invalid;
21179
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21180 return qe_invalid;
21181 25 }
21182
21183
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(keepdata==true)
21184 {
21185
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 zinit = temp_zinit;
21186
21187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(zinit.heroAnimationStyle==las_zelda3slow)
21188 {
21189 hero_animation_speed=2;
21190 }
21191 else
21192 {
21193 115 hero_animation_speed=1;
21194 }
21195 115 }
21196
21197 115 return 0;
21198 439 }
21199
21200 /*
21201 void setupitemdropsets()
21202 {
21203 for(int32_t i=0; i<isMAX; i++)
21204 {
21205 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21206 }
21207 }
21208 */
21209
21210 110 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21211 {
21212 110 build=build; // here to prevent compiler warnings
21213 dword dummy_dword;
21214 110 word item_drop_sets_to_read=0;
21215 item_drop_object tempitemdrop;
21216 110 word s_version=0, s_cversion=0;
21217
21218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata)
21219 {
21220
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 110 times.
28270 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21221 {
21222 28160 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21223 28160 }
21224 110 }
21225
21226
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4 times.
110 if(version > 0x192)
21227 {
21228 106 item_drop_sets_to_read=0;
21229
21230 //section version info
21231
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_version,f,true))
21232 {
21233 return qe_invalid;
21234 }
21235
21236 106 FFCore.quest_format[vItemDropsets] = s_version;
21237
21238 //al_trace("Item drop sets version %d\n", s_version);
21239
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
21240 {
21241 return qe_invalid;
21242 }
21243
21244 //section size
21245
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy_dword,f,true))
21246 {
21247 return qe_invalid;
21248 }
21249
21250 //finally... section data
21251
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&item_drop_sets_to_read,f,true))
21252 {
21253 return qe_invalid;
21254 }
21255
21256
2/4
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
106 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
21257 {
21258 return qe_invalid;
21259 }
21260 106 }
21261 else
21262 {
21263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21264 {
21265 4 init_item_drop_sets();
21266 4 }
21267 }
21268
21269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 106 times.
110 if(s_version>=1)
21270 {
21271
2/2
✓ Branch 0 taken 1978 times.
✓ Branch 1 taken 106 times.
2084 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21272 {
21273
1/2
✓ Branch 0 taken 1978 times.
✗ Branch 1 not taken.
1978 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21274 {
21275 return qe_invalid;
21276 }
21277
21278
2/2
✓ Branch 0 taken 19780 times.
✓ Branch 1 taken 1978 times.
21758 for(int32_t j=0; j<10; ++j)
21279 {
21280
1/2
✓ Branch 0 taken 19780 times.
✗ Branch 1 not taken.
19780 if(!p_igetw(&tempitemdrop.item[j],f,true))
21281 {
21282 return qe_invalid;
21283 }
21284 19780 }
21285
21286
2/2
✓ Branch 0 taken 21758 times.
✓ Branch 1 taken 1978 times.
23736 for(int32_t j=0; j<11; ++j)
21287 {
21288
1/2
✓ Branch 0 taken 21758 times.
✗ Branch 1 not taken.
21758 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21289 {
21290 return qe_invalid;
21291 }
21292 21758 }
21293
21294 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21295 // overrides the quest's set #12.
21296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1978 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1978 if(s_version<2 && i==12)
21297 continue;
21298
21299 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21300
1/4
✓ Branch 0 taken 1978 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1978 if(s_version<2) for(int32_t j=0; j<10; ++j)
21301 {
21302 int32_t it = tempitemdrop.item[j];
21303
21304 if((itemsbuf[it].family == itype_rupee
21305 && ((itemsbuf[it].amount)&0xFFF) == 10)
21306 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21307 {
21308 tempitemdrop.chance[j+1]=0;
21309 }
21310 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21311 {
21312 tempitemdrop.chance[j+1]=0;
21313 }
21314
21315 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21316 if(itemsbuf[it].family == itype_misc)
21317 {
21318 // If a non-gameplay item was selected, then item drop was aborted.
21319 // Reflect this by increasing the 'Nothing' chance accordingly.
21320 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21321 tempitemdrop.chance[j+1]=0;
21322 }
21323 }
21324
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1978 times.
1978 if(keepdata)
21326 {
21327 1978 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21328 1978 }
21329 1978 }
21330 106 }
21331
21332 110 return 0;
21333 110 }
21334
21335 106 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21336 {
21337 int32_t temp_num;
21338 dword dummy_dword;
21339 word num_favorite_combos;
21340 word num_favorite_combo_aliases;
21341 106 word s_version=0, s_cversion=0;
21342
21343 //section version info
21344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!p_igetw(&s_version,f,true))
21345 {
21346 return qe_invalid;
21347 }
21348
21349 106 FFCore.quest_format[vFavourites] = s_version;
21350
21351
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&s_cversion,f,true))
21352 {
21353 return qe_invalid;
21354 }
21355
21356 //section size
21357
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetl(&dummy_dword,f,true))
21358 {
21359 return qe_invalid;
21360 }
21361
21362 106 word per_row = FAVORITECOMBO_PER_ROW;
21363
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 25 times.
106 if(s_version >= 3)
21364
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&per_row,f,true))
21365 return qe_invalid;
21366 //finally... section data
21367
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&num_favorite_combos,f,true))
21368 {
21369 return qe_invalid;
21370 }
21371
21372 //Hack; port old favorite combos
21373
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
106 if(s_version < 3 && num_favorite_combos == 100)
21374 81 per_row = 13;
21375
21376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata)
21377 {
21378
2/2
✓ Branch 0 taken 31800 times.
✓ Branch 1 taken 106 times.
31906 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21379 31800 favorite_combos[q] = -1;
21380
2/2
✓ Branch 0 taken 31800 times.
✓ Branch 1 taken 106 times.
31906 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21381 31800 favorite_comboaliases[q] = -1;
21382 106 }
21383
2/2
✓ Branch 0 taken 8629 times.
✓ Branch 1 taken 106 times.
8735 for(int32_t i=0; i<num_favorite_combos; i++)
21384 {
21385
1/2
✓ Branch 0 taken 8629 times.
✗ Branch 1 not taken.
8629 if(!p_igetl(&temp_num,f,true))
21386 {
21387 return qe_invalid;
21388 }
21389
21390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8629 times.
8629 if(keepdata)
21391 {
21392
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 8100 times.
8629 if(per_row == FAVORITECOMBO_PER_ROW)
21393 529 favorite_combos[i]=temp_num;
21394 else
21395 {
21396 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21397 8100 favorite_combos[new_i]=temp_num;
21398 }
21399 8629 }
21400 8629 }
21401
21402
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21403 {
21404 return qe_invalid;
21405 }
21406
21407
2/2
✓ Branch 0 taken 8100 times.
✓ Branch 1 taken 106 times.
8206 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21408 {
21409
1/2
✓ Branch 0 taken 8100 times.
✗ Branch 1 not taken.
8100 if(!p_igetl(&temp_num,f,true))
21410 {
21411 return qe_invalid;
21412 }
21413
21414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(keepdata)
21415 {
21416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(per_row == FAVORITECOMBO_PER_ROW)
21417 favorite_comboaliases[i]=temp_num;
21418 else
21419 {
21420 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21421 8100 favorite_comboaliases[new_i]=temp_num;
21422 }
21423 8100 }
21424 8100 }
21425
21426 106 word max_combo_cols = 0;
21427 106 word max_mappages = 0;
21428
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 25 times.
106 if(s_version >= 2)
21429 {
21430
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&max_combo_cols,f,true))
21431 return qe_invalid;
21432 25 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21433
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int q = 0; q < max_combo_cols; ++q)
21434 {
21435
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp,f,true))
21436 return qe_invalid;
21437
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp2,f,true))
21438 return qe_invalid;
21439
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tmp3,f,true))
21440 return qe_invalid;
21441
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
100 if(keepdata && q < MAX_COMBO_COLS)
21442 {
21443 100 First[q] = tmp;
21444 100 combo_alistpos[q] = tmp2;
21445 100 combo_pool_listpos[q] = tmp3;
21446 100 }
21447 100 }
21448
21449
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&max_mappages,f,true))
21450 return qe_invalid;
21451
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 25 times.
250 for(int q = 0; q < max_mappages; ++q)
21452 {
21453
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_igetl(&tmp,f,true))
21454 return qe_invalid;
21455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(!p_igetl(&tmp2,f,true))
21456 return qe_invalid;
21457
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(keepdata && q < MAX_MAPPAGE_BTNS)
21458 {
21459 225 map_page[q].map = tmp;
21460 225 map_page[q].screen = tmp2;
21461 225 }
21462 225 }
21463 25 }
21464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(keepdata)
21465 {
21466
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 106 times.
430 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21467 {
21468 324 First[q] = 0;
21469 324 combo_alistpos[q] = 0;
21470 324 combo_pool_listpos[q] = 0;
21471 324 }
21472
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 106 times.
835 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21473 {
21474 729 map_page[q].map = 0;
21475 729 map_page[q].screen = 0;
21476 729 }
21477 106 }
21478
21479 106 return 0;
21480 106 }
21481
21482 /*
21483 switch (ret) {
21484 case 0:
21485 break;
21486
21487 case qe_invalid:
21488 goto invalid;
21489 break;
21490 default:
21491 pack_fclose(f);
21492 if(!oldquest)
21493 delete_file(tmpfilename);
21494 return ret;
21495 break;
21496 }
21497 */
21498
21499 const char *skip_text[skip_max]=
21500 {
21501 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21502 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21503 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21504 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21505 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21506 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21507 "skip_favorites"
21508 };
21509
21510
21511 void port250QuestRules(){
21512
21513 portCandleRules(); //Candle
21514 portBombRules();
21515
21516 }
21517
21518 void portCandleRules()
21519 {
21520 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21521 //itemdata itemsbuf;
21522 for ( int32_t q = 0; q < MAXITEMS; q++ )
21523 {
21524 if ( itemsbuf[q].family == itype_candle )
21525 {
21526 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21527 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21528 }
21529 }
21530 }
21531
21532 void portBombRules()
21533 {
21534 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21535 //itemdata itemsbuf;
21536 for ( int32_t q = 0; q < MAXITEMS; q++ )
21537 {
21538 if ( itemsbuf[q].family == itype_bomb )
21539 {
21540 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21541 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21542 }
21543 }
21544
21545 }
21546
21547 //Internal function for loadquest wrapper
21548 115 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21549 {
21550 115 DMapEditorLastMaptileUsed = 0;
21551 115 combosread=false;
21552 115 mapsread=false;
21553 115 fixffcs=false;
21554
21555
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21556 {
21557 keepall=false;
21558 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21559 }
21560
21561 // show_progress=true;
21562 char tmpfilename[L_tmpnam];
21563 115 temp_name(tmpfilename);
21564 // char percent_done[30];
21565 115 bool catchup=false;
21566 byte tempbyte;
21567 115 word old_map_count=map_count;
21568
21569 115 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21570 115 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21571 115 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21572
21573
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(keepall==false||get_bit(skip_flags, skip_rules))
21574 {
21575 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21576 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21577 }
21578
21579 115 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21580 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21581
21582
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(keepall==false||get_bit(skip_flags, skip_midis))
21583 {
21584 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21585 }
21586
21587
21588
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21589 {
21590 115 zScript.clear();
21591 115 globalmap.clear();
21592 115 genericmap.clear();
21593 115 ffcmap.clear();
21594 115 itemmap.clear();
21595 115 npcmap.clear();
21596 115 ewpnmap.clear();
21597 115 lwpnmap.clear();
21598 115 playermap.clear();
21599 115 dmapmap.clear();
21600 115 screenmap.clear();
21601 115 itemspritemap.clear();
21602 115 comboscriptmap.clear();
21603
21604
2/2
✓ Branch 0 taken 58765 times.
✓ Branch 1 taken 115 times.
58880 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21605 {
21606 58765 ffcmap[i].clear();
21607 58765 }
21608
21609 115 globalmap[0].slotname = "Slot 1:";
21610 115 globalmap[0].scriptname = "~Init";
21611 115 globalmap[0].update();
21612
21613
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 115 times.
920 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21614 {
21615 805 globalmap[i].clear();
21616 805 }
21617
21618
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21619 {
21620 29325 itemmap[i].clear();
21621 29325 }
21622
21623 //new script types -- prevent carrying over to a quest that you load after reading them
21624 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21625
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21626 {
21627 29325 npcmap[i].clear();
21628 29325 }
21629
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21630 {
21631 29325 lwpnmap[i].clear();
21632 29325 }
21633
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21634 {
21635 29325 ewpnmap[i].clear();
21636 29325 }
21637
2/2
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 115 times.
575 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21638 {
21639 460 playermap[i].clear();
21640 460 }
21641
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21642 {
21643 29325 dmapmap[i].clear();
21644 29325 }
21645
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21646 {
21647 29325 screenmap[i].clear();
21648 29325 }
21649
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21650 {
21651 29325 itemspritemap[i].clear();
21652 29325 }
21653
2/2
✓ Branch 0 taken 58765 times.
✓ Branch 1 taken 115 times.
58880 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21654 {
21655 58765 comboscriptmap[i].clear();
21656 58765 }
21657
2/2
✓ Branch 0 taken 58765 times.
✓ Branch 1 taken 115 times.
58880 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21658 {
21659 58765 genericmap[i].clear();
21660 58765 }
21661
21662 115 reset_scripts();
21663 115 }
21664
21665 zquestheader tempheader;
21666 115 memset(&tempheader, 0, sizeof(zquestheader));
21667 115 zinfo tempzi;
21668 115 tempzi.clear();
21669 115 load_tmp_zi = &tempzi;
21670
21671 // oldquest flag is set when an unencrypted qst file is suspected.
21672 115 bool oldquest = false;
21673 115 int32_t open_error=0;
21674 115 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21675
21676
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (!f)
21677 {
21678 ASSERT(open_error != 0);
21679 return open_error;
21680 }
21681 char zinfofilename[2048];
21682 115 replace_extension(zinfofilename, filename, "zinfo", 2047);
21683 115 int32_t ret=0;
21684
21685 //header
21686 115 box_out("Reading Header...");
21687 115 ret=readheader(f, &tempheader, true, printmetadata);
21688
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
115 checkstatus(ret);
21689 115 box_out("okay.");
21690 115 box_eol();
21691
21692
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 30 times.
115 if(read_zinfo)
21693 {
21694 30 box_out("Reading ZInfo - ");
21695
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 box_out(read_ext_zinfo ? "External..." : "Internal...");
21696
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 if(read_ext_zinfo)
21697 {
21698 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21699 1 ret=readzinfo(inf, tempzi, tempheader);
21700
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21701
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21702 1 }
21703 else
21704 {
21705 29 ret=readzinfo(f, tempzi, tempheader);
21706
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
29 checkstatus(ret);
21707 }
21708 30 box_out("okay.");
21709 30 box_eol();
21710 30 }
21711
21712
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if(tempheader.zelda_version>=0x193)
21713 {
21714 dword section_id;
21715
21716 //section id
21717
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_mgetl(&section_id,f,true))
21718 {
21719 return qe_invalid;
21720 }
21721
21722 111 std::set<dword> seen_sections;
21723
21724
3/4
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2619 times.
✓ Branch 3 taken 111 times.
2730 while(!pack_feof(f))
21725 {
21726
2/4
✓ Branch 0 taken 2619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2619 times.
✗ Branch 3 not taken.
2619 if (seen_sections.contains(section_id))
21727 return qe_invalid;
21728
1/2
✓ Branch 0 taken 2619 times.
✗ Branch 1 not taken.
2619 seen_sections.insert(section_id);
21729
21730
24/25
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 111 times.
✓ Branch 5 taken 106 times.
✓ Branch 6 taken 111 times.
✓ Branch 7 taken 111 times.
✓ Branch 8 taken 111 times.
✓ Branch 9 taken 111 times.
✓ Branch 10 taken 111 times.
✓ Branch 11 taken 111 times.
✓ Branch 12 taken 106 times.
✓ Branch 13 taken 106 times.
✓ Branch 14 taken 111 times.
✓ Branch 15 taken 111 times.
✓ Branch 16 taken 106 times.
✓ Branch 17 taken 106 times.
✓ Branch 18 taken 106 times.
✓ Branch 19 taken 106 times.
✓ Branch 20 taken 111 times.
✓ Branch 21 taken 111 times.
✓ Branch 22 taken 106 times.
✓ Branch 23 taken 106 times.
✗ Branch 24 not taken.
2619 switch(section_id)
21731 {
21732 case ID_RULES:
21733
21734 //rules
21735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21736 {
21737 box_out("found.");
21738 box_eol();
21739 catchup=false;
21740 }
21741
21742
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Rules...");
21743
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21744
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21745
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21746
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21747 111 break;
21748
21749 case ID_STRINGS:
21750
21751 //strings
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21753 {
21754 box_out("found.");
21755 box_eol();
21756 catchup=false;
21757 }
21758
21759
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Strings...");
21760
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21761
1/9
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21762
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21763
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21764 111 break;
21765
21766 case ID_MISC:
21767
21768 //misc data
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Misc. Data...");
21777
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21778
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21779
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21780
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21781 111 break;
21782
21783 case ID_TILES:
21784
21785 //tiles
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Tiles...");
21794
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21795
1/9
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21797
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21798 111 break;
21799
21800 case ID_COMBOS:
21801
21802 //combos
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Combos...");
21811
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21812 111 combosread=true;
21813
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21814
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21815
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21816 111 break;
21817
21818 case ID_COMBOALIASES:
21819
21820 //combo aliases
21821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
21822 {
21823 box_out("found.");
21824 box_eol();
21825 catchup=false;
21826 }
21827
21828
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Combo Aliases...");
21829
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21830
1/9
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
21831
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
21832
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
21833 106 break;
21834
21835 case ID_CSETS:
21836
21837 //color data
21838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21839 {
21840 box_out("found.");
21841 box_eol();
21842 catchup=false;
21843 }
21844
21845
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Color Data...");
21846
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21847
1/9
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21848
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21849
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21850 111 break;
21851
21852 case ID_MAPS:
21853
21854 //maps
21855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21856 {
21857 box_out("found.");
21858 box_eol();
21859 catchup=false;
21860 }
21861
21862
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Maps...");
21863
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21864 111 mapsread=true;
21865
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21866
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21867
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21868 111 break;
21869
21870 case ID_DMAPS:
21871
21872 //dmaps
21873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21874 {
21875 box_out("found.");
21876 box_eol();
21877 catchup=false;
21878 }
21879
21880
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading DMaps...");
21881
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21882
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21883
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21884
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21885 111 break;
21886
21887 case ID_DOORS:
21888
21889 //door combo sets
21890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21891 {
21892 box_out("found.");
21893 box_eol();
21894 catchup=false;
21895 }
21896
21897
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Doors...");
21898
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21899
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21900
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21901
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21902 111 break;
21903
21904 case ID_ITEMS:
21905
21906 //items
21907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21908 {
21909 box_out("found.");
21910 box_eol();
21911 catchup=false;
21912 }
21913
21914
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Items...");
21915
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21916
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21917
21918
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21919
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21920 111 break;
21921
21922 case ID_WEAPONS:
21923
21924 //weapons
21925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21926 {
21927 box_out("found.");
21928 box_eol();
21929 catchup=false;
21930 }
21931
21932
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Weapons...");
21933
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21934
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21935
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21936
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21937 111 break;
21938
21939 case ID_COLORS:
21940
21941 //misc. colors
21942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
21943 {
21944 box_out("found.");
21945 box_eol();
21946 catchup=false;
21947 }
21948
21949
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Misc. Colors...");
21950
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21951
1/9
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
21952
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
21953
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
21954 106 break;
21955
21956 case ID_ICONS:
21957
21958 //game icons
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
21960 {
21961 box_out("found.");
21962 box_eol();
21963 catchup=false;
21964 }
21965
21966
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Game Icons...");
21967
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21968
1/9
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
21969
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
21970
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
21971 106 break;
21972
21973 case ID_INITDATA:
21974
21975 //initialization data
21976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
21977 {
21978 box_out("found.");
21979 box_eol();
21980 catchup=false;
21981 }
21982
21983
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Init. Data...");
21984
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21985
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
21986
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
21987
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
21988
21989
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 111 times.
111 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21990 {
21991
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 92 times.
111 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21992 {
21993
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 setupsubscreens();
21994
21995
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19 times.
9747 for(int32_t i=0; i<MAXDMAPS; ++i)
21996 {
21997 9728 int32_t type=DMaps[i].type&dmfTYPE;
21998
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 9634 times.
9728 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21999
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22000 9728 }
22001 19 }
22002 111 }
22003
22004
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 111 times.
111 if(keepall&&!get_bit(skip_flags, skip_sfx))
22005 {
22006 111 setupsfx();
22007 111 }
22008
22009
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
22010 {
22011
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 init_item_drop_sets();
22012 111 }
22013
22014
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 111 times.
111 if(keepall&&!get_bit(skip_flags, skip_favorites))
22015 {
22016 111 init_favorites();
22017 111 }
22018
22019 111 break;
22020
22021 case ID_GUYS:
22022
22023 //guys
22024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
22025 {
22026 box_out("found.");
22027 box_eol();
22028 catchup=false;
22029 }
22030
22031
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Custom Guy Data...");
22032
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22033
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
22034
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
22035
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
22036 111 break;
22037
22038 case ID_HEROSPRITES:
22039
22040 //player sprites
22041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22042 {
22043 box_out("found.");
22044 box_eol();
22045 catchup=false;
22046 }
22047
22048
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Custom Player Sprite Data...");
22049
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
22050
1/9
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22051
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22052
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22053 106 break;
22054
22055 case ID_SUBSCREEN:
22056
22057 //custom subscreens
22058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22059 {
22060 box_out("found.");
22061 box_eol();
22062 catchup=false;
22063 }
22064
22065
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Custom Subscreen Data...");
22066
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
22067
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22068
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22069
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22070 106 break;
22071
22072 case ID_FFSCRIPT:
22073
22074 //Freeform combo scripts
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22076 {
22077 box_out("found.");
22078 box_eol();
22079 catchup=false;
22080 }
22081
22082
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading FF Script Data...");
22083
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
22084
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22085
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22086
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22087 106 break;
22088
22089 case ID_SFX:
22090
22091 //SFX data
22092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22093 {
22094 box_out("found.");
22095 box_eol();
22096 catchup=false;
22097 }
22098
22099
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading SFX Data...");
22100
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
22101
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22102
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22103
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22104 106 break;
22105
22106 case ID_MIDIS:
22107
22108 //midis
22109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
22110 {
22111 box_out("found.");
22112 box_eol();
22113 catchup=false;
22114 }
22115
22116
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Tunes...");
22117
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22118
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
22119
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
22120
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
22121 111 break;
22122
22123 case ID_CHEATS:
22124
22125 //cheat codes
22126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(catchup)
22127 {
22128 box_out("found.");
22129 box_eol();
22130 catchup=false;
22131 }
22132
22133
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("Reading Cheat Codes...");
22134
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22135
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
111 checkstatus(ret);
22136
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_out("okay.");
22137
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 box_eol();
22138 111 break;
22139
22140 case ID_ITEMDROPSETS:
22141
22142 //item drop sets
22143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22144 {
22145 box_out("found.");
22146 box_eol();
22147 catchup=false;
22148 }
22149
22150
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Item Drop Sets...");
22151
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22152
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22153
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22154
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22155 106 break;
22156
22157 case ID_FAVORITES:
22158
22159 //favorite combos and combo aliases
22160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(catchup)
22161 {
22162 box_out("found.");
22163 box_eol();
22164 catchup=false;
22165 }
22166
22167
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("Reading Favorite Combos...");
22168
3/6
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✗ Branch 5 not taken.
106 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
22169
1/9
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106 checkstatus(ret);
22170
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_out("okay.");
22171
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 box_eol();
22172 106 break;
22173
22174 default:
22175 if(!catchup)
22176 {
22177 box_out("Bad token! Searching...");
22178 box_eol();
22179 }
22180
22181 catchup=true;
22182 break;
22183 }
22184
22185
22186
1/2
✓ Branch 0 taken 2619 times.
✗ Branch 1 not taken.
2619 if(catchup)
22187 {
22188 //section id
22189 section_id=(section_id<<8);
22190
22191 if(!p_getc(&tempbyte,f,true))
22192 {
22193 return qe_invalid;
22194 }
22195
22196 section_id+=tempbyte;
22197 }
22198
22199 else
22200 {
22201 //section id
22202
3/4
✓ Branch 0 taken 2619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2508 times.
✓ Branch 3 taken 111 times.
2619 if(!pack_feof(f))
22203 {
22204
2/4
✓ Branch 0 taken 2508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2508 times.
✗ Branch 3 not taken.
2508 if(!p_mgetl(&section_id,f,true))
22205 {
22206 return qe_invalid;
22207 }
22208 2508 }
22209 }
22210 }
22211
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 111 times.
111 }
22212 else
22213 {
22214 //rules
22215 4 box_out("Reading Rules...");
22216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22217
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22218 4 box_out("okay.");
22219 4 box_eol();
22220
22221 //strings
22222 4 box_out("Reading Strings...");
22223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22224
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22225 4 box_out("okay.");
22226 4 box_eol();
22227
22228 //door combo sets
22229 4 box_out("Reading Doors...");
22230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22231
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22232 4 box_out("okay.");
22233 4 box_eol();
22234
22235 //dmaps
22236 4 box_out("Reading DMaps...");
22237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22238
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22239 4 box_out("okay.");
22240 4 box_eol();
22241
22242 // misc data
22243 4 box_out("Reading Misc. Data...");
22244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22245
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22246 4 box_out("okay.");
22247 4 box_eol();
22248
22249 //items
22250 4 box_out("Reading Items...");
22251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22252
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22253 4 box_out("okay.");
22254 4 box_eol();
22255
22256 //weapons
22257 4 box_out("Reading Weapons...");
22258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22259
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22260 4 box_out("okay.");
22261 4 box_eol();
22262
22263 //guys
22264 4 box_out("Reading Custom Guy Data...");
22265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22266
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22267 4 box_out("okay.");
22268 4 box_eol();
22269
22270 //maps
22271 4 box_out("Reading Maps...");
22272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22273 4 mapsread=true;
22274
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22275 4 box_out("okay.");
22276 4 box_eol();
22277
22278 //combos
22279 4 box_out("Reading Combos...");
22280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22281 4 combosread=true;
22282
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22283 4 box_out("okay.");
22284 4 box_eol();
22285
22286 //color data
22287 4 box_out("Reading Color Data...");
22288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22289
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22290 4 box_out("okay.");
22291 4 box_eol();
22292
22293 //tiles
22294 4 box_out("Reading Tiles...");
22295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22296
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22297 4 box_out("okay.");
22298 4 box_eol();
22299
22300 //midis
22301 4 box_out("Reading Tunes...");
22302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22303
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22304 4 box_out("okay.");
22305 4 box_eol();
22306
22307 //cheat codes
22308 4 box_out("Reading Cheat Codes...");
22309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22310
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22311 4 box_out("okay.");
22312 4 box_eol();
22313
22314 //initialization data
22315 4 box_out("Reading Init. Data...");
22316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22317
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22318 4 box_out("okay.");
22319 4 box_eol();
22320
22321
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22322 {
22323 4 setupsubscreens();
22324
22325
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22326 {
22327 2048 int32_t type=DMaps[i].type&dmfTYPE;
22328
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22329 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22330 2048 }
22331 4 }
22332
22333 4 box_out("Setting Up Default Sound Effects...");
22334
22335
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22336 4 setupsfx();
22337
22338 4 box_out("okay.");
22339 4 box_eol();
22340
22341 //player sprites
22342 4 box_out("Reading Custom Player Sprite Data...");
22343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22344
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22345 4 box_out("okay.");
22346 4 box_eol();
22347
22348 4 box_out("Setting Up Default Item Drop Sets...");
22349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22350 4 box_out("okay.");
22351 4 box_eol();
22352 }
22353
22354 115 init_spritelists();
22355
22356 // check data
22357
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(f)
22358 {
22359 115 pack_fclose(f);
22360 115 }
22361 115 clear_quest_tmpfile();
22362
22363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!oldquest)
22364 {
22365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(exists(tmpfilename))
22366 {
22367 delete_file(tmpfilename);
22368 }
22369 115 }
22370
22371
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(fixffcs && combosread && mapsread)
22372 {
22373 for(int32_t i=0; i<map_count; i++)
22374 {
22375 for(int32_t j=0; j<MAPSCRS; j++)
22376 {
22377 for(int32_t m=0; m<32; m++)
22378 {
22379 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22380 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22381 }
22382 }
22383 }
22384 }
22385
22386
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 93 times.
115 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22387 {
22388 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22389 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22390 22 zinit.cont_heart=100;
22391 22 zinit.start_heart=zinit.hc;
22392 22 }
22393
22394 115 box_out("Done.");
22395 115 box_eol();
22396 115 box_end(false);
22397
22398 // if (keepall==true||!get_bit(skip_flags, skip_header))
22399
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(keepall&&!get_bit(skip_flags, skip_header))
22400 {
22401 115 memcpy(Header, &tempheader, sizeof(tempheader));
22402 115 }
22403
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22404 {
22405 115 ZI.copyFrom(tempzi);
22406 115 }
22407
22408
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(!keepall||get_bit(skip_flags, skip_maps))
22409 {
22410 map_count=old_map_count;
22411 }
22412
22413
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(!keepall||get_bit(skip_flags, skip_rules))
22414 {
22415 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22416 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22417 }
22418
22419
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if(!keepall||get_bit(skip_flags, skip_midis))
22420 {
22421 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22422 }
22423
22424 //Debug FFCore.quest_format[]
22425 115 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22426 115 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22427 115 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22428 115 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22429 115 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22430 115 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22431 115 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22432 115 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22433 115 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22434 115 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22435 115 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22436 115 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22437 115 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22438 115 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22439 115 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22440 115 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22441 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22442 115 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22443 115 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22444 115 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22445 115 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22446 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22447 115 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22448 115 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22449 115 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22450 115 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22451 115 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22452 115 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22453 115 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22454 115 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22455 //Print metadata for versions under 2.10 here. Bleah.
22456
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 4 times.
115 if( FFCore.quest_format[vZelda] < 0x210 )
22457 {
22458 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22459
22460
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22461 {
22462 case 0x193:
22463 {
22464 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22465 }
22466 case 0x192:
22467 {
22468 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22469 }
22470 case 0x190:
22471 {
22472 4 zprint2("Last saved in ZC Editor Version: 1.90");
22473
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22474 4 else zprint2("\n");
22475 4 break;
22476 }
22477 case 0x188:
22478 {
22479 zprint2("Last saved in ZC Editor Version: 1.88");
22480 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22481 else zprint2("\n");
22482 break;
22483 }
22484 case 0x187:
22485 {
22486 zprint2("Last saved in ZC Editor Version: 1.87");
22487 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22488 else zprint2("\n");
22489 break;
22490 }
22491 case 0x186:
22492 {
22493 zprint2("Last saved in ZC Editor Version: 1.86");
22494 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22495 else zprint2("\n");
22496 break;
22497 }
22498 case 0x185:
22499 {
22500 zprint2("Last saved in ZC Editor Version: 1.85");
22501 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22502 else zprint2("\n");
22503 break;
22504 }
22505 case 0x184:
22506 {
22507 zprint2("Last saved in ZC Editor Version: 1.84");
22508 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22509 else zprint2("\n");
22510 break;
22511 }
22512 case 0x183:
22513 {
22514 zprint2("Last saved in ZC Editor Version: 1.83");
22515 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22516 else zprint2("\n");
22517 break;
22518 }
22519 case 0x182:
22520 {
22521 zprint2("Last saved in ZC Editor Version: 1.82");
22522 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22523 else zprint2("\n");
22524 break;
22525 }
22526 case 0x181:
22527 {
22528 zprint2("Last saved in ZC Editor Version: 1.81");
22529 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22530 else zprint2("\n");
22531 break;
22532 }
22533 case 0x180:
22534 {
22535 zprint2("Last saved in ZC Editor Version: 1.80");
22536 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22537 else zprint2("\n");
22538 break;
22539 }
22540 default:
22541 {
22542 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22543 }
22544 }
22545 4 }
22546
22547 115 return qe_OK;
22548
22549 invalid:
22550 box_out("error.");
22551 box_eol();
22552 box_end(true);
22553
22554 if(f)
22555 {
22556 pack_fclose(f);
22557 }
22558
22559 if(!oldquest)
22560 {
22561 if(exists(tmpfilename))
22562 {
22563 delete_file(tmpfilename);
22564 }
22565 }
22566
22567 return qe_invalid;
22568
22569 115 }
22570
22571 115 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22572 {
22573 115 loading_qst_name = filename;
22574 115 loading_qst_num = qst_num;
22575 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22576 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22577
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (!is_ci())
22578 loadquest_report = report;
22579 115 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22580 115 load_tmp_zi = NULL;
22581 115 loading_qst_name = NULL;
22582 115 loadquest_report = false;
22583 115 loading_qst_num = 0;
22584 115 return ret;
22585 }
22586